X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft5512-ls-remote.sh;h=d1912351db7da4a7c457fd44895b5ea076c84e7e;hb=bcacc0ebdb17b55040826bf82d1bde4070119250;hp=1dd8eed5bb3cb0f320a8f0780452e52fa7d8da16;hpb=00d3278c8534a8244ae3447189401111e017fd5d;p=git.git diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index 1dd8eed5b..d1912351d 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -49,4 +49,78 @@ test_expect_success 'ls-remote self' ' ' +test_expect_success 'dies when no remote specified and no default remotes found' ' + + test_must_fail git ls-remote + +' + +test_expect_success 'use "origin" when no remote specified' ' + + URL="$(pwd)/.git" && + echo "From $URL" >exp_err && + + git remote add origin "$URL" && + git ls-remote 2>actual_err >actual && + + test_cmp exp_err actual_err && + test_cmp expected.all actual + +' + +test_expect_success 'suppress "From " with -q' ' + + git ls-remote -q 2>actual_err && + test_must_fail test_cmp exp_err actual_err + +' + +test_expect_success 'use branch..remote if possible' ' + + # + # Test that we are indeed using branch..remote, not "origin", even + # though the "origin" remote has been set. + # + + # setup a new remote to differentiate from "origin" + git clone . other.git && + ( + cd other.git && + echo "$(git rev-parse HEAD) HEAD" + git show-ref | sed -e "s/ / /" + ) >exp && + + URL="other.git" && + echo "From $URL" >exp_err && + + git remote add other $URL && + git config branch.master.remote other && + + git ls-remote 2>actual_err >actual && + test_cmp exp_err actual_err && + test_cmp exp actual + +' + +cat >exp <" to work; ls-remote, correctly, + # confuses for . Although ugly, this behaviour is akin + # to the confusion of refspecs for remotes by git-fetch and git-push, + # eg: + # + # $ git fetch branch + # + + # We could just as easily have used "master"; the "*" emphasizes its + # role as a pattern. + test_must_fail git ls-remote refs*master >actual 2>&1 && + test_cmp exp actual + +' + test_done