Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t2019-checkout-ambiguous-ref.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t2019-checkout-ambiguous-ref.sh` 60 lines ยท 1504 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='checkout handling of ambiguous (branch/tag) refs' 4 5 . ./test-lib.sh 6 7 test_expect_success 'setup ambiguous refs' ' 8 test_commit branch file && 9 git branch ambiguity && 10 git branch vagueness && 11 test_commit tag file && 12 git tag ambiguity && 13 git tag vagueness HEAD:file && 14 test_commit other file 15 ' 16 17 test_expect_success 'checkout ambiguous ref succeeds' ' 18 git checkout ambiguity 2>stderr 19 ' 20 21 test_expect_success 'checkout produces ambiguity warning' ' 22 test_grep "warning.*ambiguous" stderr 23 ' 24 25 test_expect_success 'checkout chooses branch over tag' ' 26 echo refs/heads/ambiguity >expect && 27 git symbolic-ref HEAD >actual && 28 test_cmp expect actual && 29 echo branch >expect && 30 test_cmp expect file 31 ' 32 33 test_expect_success 'checkout reports switch to branch' ' 34 test_grep "Switched to branch" stderr && 35 test_grep ! "^HEAD is now at" stderr 36 ' 37 38 test_expect_success 'checkout vague ref succeeds' ' 39 git checkout vagueness 2>stderr && 40 test_set_prereq VAGUENESS_SUCCESS 41 ' 42 43 test_expect_success VAGUENESS_SUCCESS 'checkout produces ambiguity warning' ' 44 test_grep "warning.*ambiguous" stderr 45 ' 46 47 test_expect_success VAGUENESS_SUCCESS 'checkout chooses branch over tag' ' 48 echo refs/heads/vagueness >expect && 49 git symbolic-ref HEAD >actual && 50 test_cmp expect actual && 51 echo branch >expect && 52 test_cmp expect file 53 ' 54 55 test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' ' 56 test_grep "Switched to branch" stderr && 57 test_grep ! "^HEAD is now at" stderr 58 ' 59 60 test_done