diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2015-07-01 18:08:14 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-07-01 09:30:53 -0700 |
commit | ae454f6125dd492c78eaf0b8709d4779bc0cbe7a (patch) | |
tree | 8b3d06e966da77854e74812852d44d352d47be01 /t/t2019-checkout-ambiguous-ref.sh | |
parent | pathspec: avoid the need of "--" when wildcard is used (diff) | |
download | tgif-ae454f6125dd492c78eaf0b8709d4779bc0cbe7a.tar.xz |
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>
Diffstat (limited to 't/t2019-checkout-ambiguous-ref.sh')
-rwxr-xr-x | t/t2019-checkout-ambiguous-ref.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/t/t2019-checkout-ambiguous-ref.sh b/t/t2019-checkout-ambiguous-ref.sh index b99d5192a9..8396320d52 100755 --- a/t/t2019-checkout-ambiguous-ref.sh +++ b/t/t2019-checkout-ambiguous-ref.sh @@ -56,4 +56,30 @@ test_expect_success VAGUENESS_SUCCESS 'checkout reports switch to branch' ' test_i18ngrep ! "^HEAD is now at" stderr ' +test_expect_success 'wildcard ambiguation, paths win' ' + git init ambi && + ( + cd ambi && + echo a >a.c && + git add a.c && + echo b >a.c && + git checkout "*.c" && + echo a >expect && + test_cmp expect a.c + ) +' + +test_expect_success 'wildcard ambiguation, refs lose' ' + git init ambi2 && + ( + cd ambi2 && + echo a >"*.c" && + git add . && + test_must_fail git show :"*.c" && + git show :"*.c" -- >actual && + echo a >expect && + test_cmp expect actual + ) +' + test_done |