]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2019-checkout-ambiguous-ref.sh
The third batch
[thirdparty/git.git] / t / t2019-checkout-ambiguous-ref.sh
CommitLineData
0cb6ad3c
JH
1#!/bin/sh
2
3test_description='checkout handling of ambiguous (branch/tag) refs'
9081a421
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
0cb6ad3c
JH
6. ./test-lib.sh
7
8test_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
18test_expect_success 'checkout ambiguous ref succeeds' '
a5855fd8 19 git checkout ambiguity 2>stderr
0cb6ad3c
JH
20'
21
22test_expect_success 'checkout produces ambiguity warning' '
23 grep "warning.*ambiguous" stderr
24'
25
26test_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 34test_expect_success 'checkout reports switch to branch' '
6789275d
JH
35 test_grep "Switched to branch" stderr &&
36 test_grep ! "^HEAD is now at" stderr
0cb6ad3c
JH
37'
38
39test_expect_success 'checkout vague ref succeeds' '
a5855fd8 40 git checkout vagueness 2>stderr &&
0cb6ad3c
JH
41 test_set_prereq VAGUENESS_SUCCESS
42'
43
44test_expect_success VAGUENESS_SUCCESS 'checkout produces ambiguity warning' '
45 grep "warning.*ambiguous" stderr
46'
47
48test_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 56test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' '
6789275d
JH
57 test_grep "Switched to branch" stderr &&
58 test_grep ! "^HEAD is now at" stderr
0cb6ad3c
JH
59'
60
61test_done