]>
Commit | Line | Data |
---|---|---|
0cb6ad3c JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='checkout handling of ambiguous (branch/tag) refs' | |
9081a421 ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
0cb6ad3c JH |
6 | . ./test-lib.sh |
7 | ||
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 && | |
13 | git tag ambiguity && | |
14 | git tag vagueness HEAD:file && | |
15 | test_commit other file | |
16 | ' | |
17 | ||
18 | test_expect_success 'checkout ambiguous ref succeeds' ' | |
19 | git checkout ambiguity >stdout 2>stderr | |
20 | ' | |
21 | ||
22 | test_expect_success 'checkout produces ambiguity warning' ' | |
23 | grep "warning.*ambiguous" stderr | |
24 | ' | |
25 | ||
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 && | |
31 | test_cmp expect file | |
32 | ' | |
33 | ||
d3bd0425 JH |
34 | test_expect_success 'checkout reports switch to branch' ' |
35 | test_i18ngrep "Switched to branch" stderr && | |
36 | test_i18ngrep ! "^HEAD is now at" stderr | |
0cb6ad3c JH |
37 | ' |
38 | ||
39 | test_expect_success 'checkout vague ref succeeds' ' | |
40 | git checkout vagueness >stdout 2>stderr && | |
41 | test_set_prereq VAGUENESS_SUCCESS | |
42 | ' | |
43 | ||
44 | test_expect_success VAGUENESS_SUCCESS 'checkout produces ambiguity warning' ' | |
45 | grep "warning.*ambiguous" stderr | |
46 | ' | |
47 | ||
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 && | |
53 | test_cmp expect file | |
54 | ' | |
55 | ||
d3bd0425 JH |
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 | |
0cb6ad3c JH |
59 | ' |
60 | ||
61 | test_done |