interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t2019-checkout-ambiguous-ref.sh

60 lines · 1504 bytes Raw Blame History
1#!/bin/sh
2
3test_description='checkout handling of ambiguous (branch/tag) refs'
4
5. ./test-lib.sh
6
7test_expect_success 'setup ambiguous refs' '
8 test_commit branch file &&
9 git branch ambiguity &&
10 git branch vagueness &&
11 test_commit tag file &&
12 git tag ambiguity &&
13 git tag vagueness HEAD:file &&
14 test_commit other file
15'
16
17test_expect_success 'checkout ambiguous ref succeeds' '
18 git checkout ambiguity 2>stderr
19'
20
21test_expect_success 'checkout produces ambiguity warning' '
22 test_grep "warning.*ambiguous" stderr
23'
24
25test_expect_success 'checkout chooses branch over tag' '
26 echo refs/heads/ambiguity >expect &&
27 git symbolic-ref HEAD >actual &&
28 test_cmp expect actual &&
29 echo branch >expect &&
30 test_cmp expect file
31'
32
33test_expect_success 'checkout reports switch to branch' '
34 test_grep "Switched to branch" stderr &&
35 test_grep ! "^HEAD is now at" stderr
36'
37
38test_expect_success 'checkout vague ref succeeds' '
39 git checkout vagueness 2>stderr &&
40 test_set_prereq VAGUENESS_SUCCESS
41'
42
43test_expect_success VAGUENESS_SUCCESS 'checkout produces ambiguity warning' '
44 test_grep "warning.*ambiguous" stderr
45'
46
47test_expect_success VAGUENESS_SUCCESS 'checkout chooses branch over tag' '
48 echo refs/heads/vagueness >expect &&
49 git symbolic-ref HEAD >actual &&
50 test_cmp expect actual &&
51 echo branch >expect &&
52 test_cmp expect file
53'
54
55test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' '
56 test_grep "Switched to branch" stderr &&
57 test_grep ! "^HEAD is now at" stderr
58'
59
60test_done