That was the intention, but it raises a question: what do we do if a file happens to have the same name with the given magic pathspec, as in the last two tests? People can fall into these cases with "git add *" or something like that. I'm tempted to reuse "--" the second time to say "no more magic from here". But there may be better way to deal with it. Also, long magic must be quoted or at least bash will complain. Is there any other syntax option that can be used directly without quoting? --- t/t3703-add-magic-pathspec.sh | 68 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) create mode 100755 t/t3703-add-magic-pathspec.sh diff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh new file mode 100755 index 0000000..76108ae --- /dev/null +++ b/t/t3703-add-magic-pathspec.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +test_description='magic pathspec tests using git-add' + +. ./test-lib.sh + +test_expect_success 'setup' ' + mkdir sub anothersub && + : >sub/foo && + : >anothersub/foo +' + +test_expect_success 'colon alone magic can only used alone' ' + test_must_fail git add -n sub/foo : && + test_must_fail git add -n : sub/foo +' + +cat >expected <<EOF +add 'anothersub/foo' +add 'expected' +add 'sub/actual' +add 'sub/foo' +EOF + +test_expect_success 'add :' ' + (cd sub && git add -n : >actual) && + test_cmp expected sub/actual +' + +test_expect_success 'add :/' ' + (cd sub && git add -n :/ >actual) && + test_cmp expected sub/actual +' + +cat >expected <<EOF +add 'anothersub/foo' +EOF + +test_expect_success 'add :/anothersub' ' + (cd sub && git add -n :/anothersub >actual) && + test_cmp expected sub/actual +' + +test_expect_success 'add :/non-existent' ' + (cd sub && test_must_fail git add -n :/non-existent) +' + +cat >expected <<EOF +add 'sub/foo' +EOF + +test_expect_success 'add :(icase)foo' ' + (cd sub && git add -n ":(icase)FoO" >actual) && + test_cmp expected sub/actual +' + +test_expect_success 'a file with the same (long) magic name exists' ' + : >":(case)ha" && + git add -n ":(icase)ha" +' + +test_expect_success 'a file with the same (short) magic name exists' ' + mkdir ":" && + : >":/bar" && + git add -n :/bar +' + +test_done -- 1.7.4.74.g639db -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html