Skip to content

Commit ae454f6

Browse files
pcloudsgitster
authored andcommitted
Add tests for wildcard "path vs ref" disambiguation
Commit 28fcc0b (pathspec: avoid the need of "--" when wildcard is used - 2015-05-02) changes how the disambiguation rules work. This patch adds some tests to demonstrate, basically, if wildcard characters are in an argument: - if the argument is valid extended sha-1 syntax, "--" must be used - otherwise the argument is considered a path, even without "--" And wildcard can appear in extended sha-1 syntax, either as part of regex in ":/<regex>" or as the literal path in ":<path>". The latter case is less likely to happen in real world. But if you do ":/" a lot, you may need to type "--" more. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28fcc0b commit ae454f6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

t/t2019-checkout-ambiguous-ref.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,30 @@ test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' '
5656
test_i18ngrep ! "^HEAD is now at" stderr
5757
'
5858

59+
test_expect_success 'wildcard ambiguation, paths win' '
60+
git init ambi &&
61+
(
62+
cd ambi &&
63+
echo a >a.c &&
64+
git add a.c &&
65+
echo b >a.c &&
66+
git checkout "*.c" &&
67+
echo a >expect &&
68+
test_cmp expect a.c
69+
)
70+
'
71+
72+
test_expect_success 'wildcard ambiguation, refs lose' '
73+
git init ambi2 &&
74+
(
75+
cd ambi2 &&
76+
echo a >"*.c" &&
77+
git add . &&
78+
test_must_fail git show :"*.c" &&
79+
git show :"*.c" -- >actual &&
80+
echo a >expect &&
81+
test_cmp expect actual
82+
)
83+
'
84+
5985
test_done

0 commit comments

Comments
 (0)