3 test_description
='checkout handling of ambiguous (branch/tag) refs'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup ambiguous refs' '
9 test_commit branch file &&
10 git branch ambiguity &&
11 git branch vagueness &&
12 test_commit tag file &&
14 git tag vagueness HEAD:file &&
15 test_commit other file
18 test_expect_success
'checkout ambiguous ref succeeds' '
19 git checkout ambiguity >stdout 2>stderr
22 test_expect_success
'checkout produces ambiguity warning' '
23 grep "warning.*ambiguous" stderr
26 test_expect_success
'checkout chooses branch over tag' '
27 echo refs/heads/ambiguity >expect &&
28 git symbolic-ref HEAD >actual &&
29 test_cmp expect actual &&
30 echo branch >expect &&
34 test_expect_success
'checkout reports switch to branch' '
35 test_i18ngrep "Switched to branch" stderr &&
36 test_i18ngrep ! "^HEAD is now at" stderr
39 test_expect_success
'checkout vague ref succeeds' '
40 git checkout vagueness >stdout 2>stderr &&
41 test_set_prereq VAGUENESS_SUCCESS
44 test_expect_success VAGUENESS_SUCCESS
'checkout produces ambiguity warning' '
45 grep "warning.*ambiguous" stderr
48 test_expect_success VAGUENESS_SUCCESS
'checkout chooses branch over tag' '
49 echo refs/heads/vagueness >expect &&
50 git symbolic-ref HEAD >actual &&
51 test_cmp expect actual &&
52 echo branch >expect &&
56 test_expect_success VAGUENESS_SUCCESS
'checkout reports switch to branch' '
57 test_i18ngrep "Switched to branch" stderr &&
58 test_i18ngrep ! "^HEAD is now at" stderr