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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jul 1, 2015 at 18:08 UTC ae454f6125dd492c78eaf0b8709d4779bc0cbe7a
1 file changed +26
t/t2019-checkout-ambiguous-ref.sh
+26
@@ -56,4 +56,30 @@ test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' '
56 test_i18ngrep ! "^HEAD is now at" stderr
57 '
58
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 +
85 test_done