X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft7201-co.sh;h=ed2e9ee3c6fea4767f0aa288dca02825569abedf;hb=55246aac6717e86c14f31391ac903ed810d1a9a0;hp=5fa6a45577894e05446351fc5076a27accb1fa9f;hpb=3e0318a3613ae8e89dcb1fc39d909145e64287b9;p=git.git diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 5fa6a4557..ed2e9ee3c 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -190,4 +190,44 @@ test_expect_success 'checkout to detach HEAD with HEAD^0' ' fi ' +test_expect_success 'checkout with ambiguous tag/branch names' ' + + git tag both side && + git branch both master && + git reset --hard && + git checkout master && + + git checkout both && + H=$(git rev-parse --verify HEAD) && + M=$(git show-ref -s --verify refs/heads/master) && + test "z$H" = "z$M" && + name=$(git symbolic-ref HEAD 2>/dev/null) && + test "z$name" = zrefs/heads/both + +' + +test_expect_success 'checkout with ambiguous tag/branch names' ' + + git reset --hard && + git checkout master && + + git tag frotz side && + git branch frotz master && + git reset --hard && + git checkout master && + + git checkout tags/frotz && + H=$(git rev-parse --verify HEAD) && + S=$(git show-ref -s --verify refs/heads/side) && + test "z$H" = "z$S" && + if name=$(git symbolic-ref HEAD 2>/dev/null) + then + echo "Bad -- should have detached" + false + else + : happy + fi + +' + test_done