3 test_description='checkout handling of ambiguous (branch/tag) refs'
6 test_expect_success 'setup ambiguous refs' '
7 test_commit branch file &&
8 git branch ambiguity &&
9 git branch vagueness &&
10 test_commit tag file &&
12 git tag vagueness HEAD:file &&
13 test_commit other file
16 test_expect_success 'checkout ambiguous ref succeeds' '
17 git checkout ambiguity >stdout 2>stderr
20 test_expect_success 'checkout produces ambiguity warning' '
21 grep "warning.*ambiguous" stderr
24 test_expect_success 'checkout chooses branch over tag' '
25 echo refs/heads/ambiguity >expect &&
26 git symbolic-ref HEAD >actual &&
27 test_cmp expect actual &&
28 echo branch >expect &&
32 test_expect_success 'checkout reports switch to branch' '
33 test_i18ngrep "Switched to branch" stderr &&
34 test_i18ngrep ! "^HEAD is now at" stderr
37 test_expect_success 'checkout vague ref succeeds' '
38 git checkout vagueness >stdout 2>stderr &&
39 test_set_prereq VAGUENESS_SUCCESS
42 test_expect_success VAGUENESS_SUCCESS 'checkout produces ambiguity warning' '
43 grep "warning.*ambiguous" stderr
46 test_expect_success VAGUENESS_SUCCESS 'checkout chooses branch over tag' '
47 echo refs/heads/vagueness >expect &&
48 git symbolic-ref HEAD >actual &&
49 test_cmp expect actual &&
50 echo branch >expect &&
54 test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' '
55 test_i18ngrep "Switched to branch" stderr &&
56 test_i18ngrep ! "^HEAD is now at" stderr
59 test_expect_success 'wildcard ambiguation, paths win' '
72 test_expect_success 'wildcard ambiguation, refs lose' '
78 test_must_fail git show :"*.c" &&
79 git show :"*.c" -- >actual &&
81 test_cmp expect actual