diff options
author | Michael Schubert <mschub@elegosoft.com> | 2011-05-18 22:06:00 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-18 14:37:46 -0700 |
commit | a87247731e46255567ec58df940adb697e5b95a8 (patch) | |
tree | 97e0132adc9036261df4ad278577c3770b77ebe7 /t/t5512-ls-remote.sh | |
parent | b602ed7dea968d72c5b3f61ca016de7f285d80ef (diff) | |
download | git-a87247731e46255567ec58df940adb697e5b95a8.tar.gz git-a87247731e46255567ec58df940adb697e5b95a8.tar.xz |
ls-remote: the --exit-code option reports "no matching refs"
The "git ls-remote" uses its exit status to indicate if it successfully
talked with the remote repository. A new option "--exit-code" makes the
command exit with status "2" when there is no refs to be listed, even when
the command successfully talked with the remote repository.
This way, the caller can tell if we failed to contact the remote, or the
remote did not have what we wanted to see. Of course, you can inspect the
output from the command, which has been and will continue to be a valid
way to check the same thing.
Signed-off-by: Michael Schubert <mschub@elegosoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5512-ls-remote.sh')
-rwxr-xr-x | t/t5512-ls-remote.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index d1912351d..5c546c99a 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -123,4 +123,28 @@ test_expect_success 'confuses pattern as remote when no remote specified' ' ' +test_expect_success 'die with non-2 for wrong repository even with --exit-code' ' + git ls-remote --exit-code ./no-such-repository ;# not && + status=$? && + test $status != 2 && test $status != 0 +' + +test_expect_success 'Report success even when nothing matches' ' + git ls-remote other.git "refs/nsn/*" >actual && + >expect && + test_cmp expect actual +' + +test_expect_success 'Report no-match with --exit-code' ' + test_expect_code 2 git ls-remote --exit-code other.git "refs/nsn/*" >actual && + >expect && + test_cmp expect actual +' + +test_expect_success 'Report match with --exit-code' ' + git ls-remote --exit-code other.git "refs/tags/*" >actual && + git ls-remote . tags/mark >expect && + test_cmp expect actual +' + test_done |