clone_submodule: avoid using `access()` on directories
[git.git] / t / t2019-checkout-ambiguous-ref.sh
blob2c8c926b4d73a32a23380ec347e6c89c5a8e9657
1 #!/bin/sh
3 test_description='checkout handling of ambiguous (branch/tag) refs'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
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
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 &&
31 test_cmp expect file
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 &&
53 test_cmp expect file
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
61 test_done