{"thread":{"id":"27292","subject":"[PATCH] t3703: add test cases for pathspec magic","startedAt":"2011-05-07T10:35:07Z","lastAt":"2011-05-29T20:36:31Z","messageCount":28,"participants":["Nguyễn Thái Ngọc Duy","Junio C Hamano","Nguyen Thai Ngoc Duy","Thiago Farina","Johannes Sixt","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"167317","messageId":"1304764507-27547-1-git-send-email-pclouds@gmail.com","threadId":"27292","inReplyTo":null,"subject":"[PATCH] t3703: add test cases for pathspec magic","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-05-07T10:35:07Z","receivedAt":"2011-05-07T10:35:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"That was the intention, but it raises a question: what do we do if a\nfile happens to have the same name with the given magic pathspec, as\nin the last two tests? People can fall into these cases with\n\"git add *\" or something like that.\n\nI'm tempted to reuse \"--\" the second time to say \"no more magic from\nhere\". But there may be better way to deal with it.\n\nAlso, long magic must be quoted or at least bash will complain. Is\nthere any other syntax option that can be used directly without quoting?\n---\n t/t3703-add-magic-pathspec.sh |   68 +++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 68 insertions(+), 0 deletions(-)\n create mode 100755 t/t3703-add-magic-pathspec.sh\n\ndiff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh\nnew file mode 100755\nindex 0000000..76108ae\n--- /dev/null\n+++ b/t/t3703-add-magic-pathspec.sh\n@@ -0,0 +1,68 @@\n+#!/bin/sh\n+\n+test_description='magic pathspec tests using git-add'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\tmkdir sub anothersub &&\n+\t: >sub/foo &&\n+\t: >anothersub/foo\n+'\n+\n+test_expect_success 'colon alone magic can only used alone' '\n+\ttest_must_fail git add -n sub/foo : &&\n+\ttest_must_fail git add -n : sub/foo\n+'\n+\n+cat >expected <<EOF\n+add 'anothersub/foo'\n+add 'expected'\n+add 'sub/actual'\n+add 'sub/foo'\n+EOF\n+\n+test_expect_success 'add :' '\n+\t(cd sub && git add -n : >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'add :/' '\n+\t(cd sub && git add -n :/ >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+cat >expected <<EOF\n+add 'anothersub/foo'\n+EOF\n+\n+test_expect_success 'add :/anothersub' '\n+\t(cd sub && git add -n :/anothersub >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'add :/non-existent' '\n+\t(cd sub && test_must_fail git add -n :/non-existent)\n+'\n+\n+cat >expected <<EOF\n+add 'sub/foo'\n+EOF\n+\n+test_expect_success 'add :(icase)foo' '\n+\t(cd sub && git add -n \":(icase)FoO\" >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'a file with the same (long) magic name exists' '\n+\t: >\":(case)ha\" &&\n+\tgit add -n \":(icase)ha\"\n+'\n+\n+test_expect_success 'a file with the same (short) magic name exists' '\n+\tmkdir \":\" &&\n+\t: >\":/bar\" &&\n+\tgit add -n :/bar\n+'\n+\n+test_done\n-- \n1.7.4.74.g639db\n"},{"id":"167331","messageId":"7vwri2wd8x.fsf@alter.siamese.dyndns.org","threadId":"27292","inReplyTo":"1304764507-27547-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] t3703: add test cases for pathspec magic","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-07T18:56:46Z","receivedAt":"2011-05-07T18:56:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> That was the intention, but it raises a question: what do we do if a\n> file happens to have the same name with the given magic pathspec, as\n> in the last two tests?\n\nI would have expected that in such a case the user would pass a \"\\:\" or\neven \":::\" to match the file \":\", and \"\\:(rubbish)\" to match the file\n\":(rubbish)\".  The whole \":\" is special thing comes from the observation\nthat a path that begins with a colon is rare, so it is Ok to require the\nuser to do some more work (typing an extra backslash) when he really wants\nto match with such a thing.\n\nA script that takes a pathname that is meant to be a literal from the user\nin its variable $x would pass \":(noglob)$x\" when it wants to be strict.  A\nscript that lets the user say whatever and wants to pass would just pass\n\"$x\" along the callchain.\n\nI do not expect this to be an issue in practice, though.  Have you seen a\nscript that tries to quote all the possible globbing characters in \"$x\"\nbefore calling into git with the current codebase without this magic?\n"},{"id":"167357","messageId":"BANLkTikLxUtagAcujR8nzALnpUq-KHujtg@mail.gmail.com","threadId":"27292","inReplyTo":"7vwri2wd8x.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t3703: add test cases for pathspec magic","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-05-08T09:59:57Z","receivedAt":"2011-05-08T09:59:57Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2011/5/8 Junio C Hamano <gitster@pobox.com>:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>> That was the intention, but it raises a question: what do we do if a\n>> file happens to have the same name with the given magic pathspec, as\n>> in the last two tests?\n>\n> I would have expected that in such a case the user would pass a \"\\:\" or\n> even \":::\" to match the file \":\", and \"\\:(rubbish)\" to match the file\n> \":(rubbish)\".  The whole \":\" is special thing comes from the observation\n> that a path that begins with a colon is rare, so it is Ok to require the\n> user to do some more work (typing an extra backslash) when he really wants\n> to match with such a thing.\n>\n> A script that takes a pathname that is meant to be a literal from the user\n> in its variable $x would pass \":(noglob)$x\" when it wants to be strict.  A\n> script that lets the user say whatever and wants to pass would just pass\n> \"$x\" along the callchain.\n>\n> I do not expect this to be an issue in practice, though.  Have you seen a\n> script that tries to quote all the possible globbing characters in \"$x\"\n> before calling into git with the current codebase without this magic?\n\nPoint taken.\n-- \nDuy\n"},{"id":"167362","messageId":"1304852906-29272-1-git-send-email-pclouds@gmail.com","threadId":"27292","inReplyTo":"1304764507-27547-1-git-send-email-pclouds@gmail.com","subject":"[PATCH] t3703, t4208: add test cases for magic pathspec","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-05-08T11:08:26Z","receivedAt":"2011-05-08T11:08:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"While at it, also document \":\" syntax.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n v2.\n\n Documentation/glossary-content.txt |    3 +\n t/t3703-add-magic-pathspec.sh      |   78 ++++++++++++++++++++++++++++++++++++\n t/t4208-log-magic-pathspec.sh      |   40 ++++++++++++++++++\n 3 files changed, 121 insertions(+), 0 deletions(-)\n create mode 100755 t/t3703-add-magic-pathspec.sh\n create mode 100755 t/t4208-log-magic-pathspec.sh\n\ndiff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt\nindex 0ca029b..02cea08 100644\n--- a/Documentation/glossary-content.txt\n+++ b/Documentation/glossary-content.txt\n@@ -311,6 +311,9 @@ parenthesis `(`, a comma-separated list of zero or more \"magic words\",\n and a close parentheses `)`, and the remainder is the pattern to match\n against the path.\n +\n+A pathspec with only a colon means \"there is no pathspec\". This form\n+cannot be combined with other pathspec.\n++\n The \"magic signature\" consists of an ASCII symbol that is not\n alphanumeric.\n +\ndiff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh\nnew file mode 100755\nindex 0000000..3d8c6b8\n--- /dev/null\n+++ b/t/t3703-add-magic-pathspec.sh\n@@ -0,0 +1,78 @@\n+#!/bin/sh\n+\n+test_description='magic pathspec tests using git-add'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\tmkdir sub anothersub &&\n+\t: >sub/foo &&\n+\t: >anothersub/foo\n+'\n+\n+test_expect_failure 'colon alone magic can only used alone' '\n+\ttest_must_fail git add -n sub/foo : &&\n+\ttest_must_fail git add -n : sub/foo\n+'\n+\n+cat >expected <<EOF\n+add 'anothersub/foo'\n+add 'expected'\n+add 'sub/actual'\n+add 'sub/foo'\n+EOF\n+\n+test_expect_success 'add :' '\n+\t(cd sub && git add -n : >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'add :/' '\n+\t(cd sub && git add -n :/ >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+cat >expected <<EOF\n+add 'anothersub/foo'\n+EOF\n+\n+test_expect_success 'add :/anothersub' '\n+\t(cd sub && git add -n :/anothersub >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'add :/non-existent' '\n+\t(cd sub && test_must_fail git add -n :/non-existent)\n+'\n+\n+cat >expected <<EOF\n+add 'sub/foo'\n+EOF\n+\n+test_expect_success 'add :(icase)foo' '\n+\t(cd sub && git add -n \":(icase)FoO\" >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'a file with the same (long) magic name exists' '\n+\t: >\":(icase)ha\" &&\n+\ttest_must_fail git add -n \":(icase)ha\" 2>error &&\n+\tgit add -n \"./:(icase)ha\"\n+'\n+\n+cat >expected <<EOF\n+fatal: pathspec ':(icase)ha' did not match any files\n+EOF\n+\n+test_expect_failure 'show pathspecs exactly what are typed in' '\n+\ttest_cmp expected error\n+'\n+\n+test_expect_success 'a file with the same (short) magic name exists' '\n+\tmkdir \":\" &&\n+\t: >\":/bar\" &&\n+\ttest_must_fail git add -n :/bar &&\n+\tgit add -n \"./:/bar\"\n+'\n+\n+test_done\ndiff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh\nnew file mode 100755\nindex 0000000..b296a74\n--- /dev/null\n+++ b/t/t4208-log-magic-pathspec.sh\n@@ -0,0 +1,40 @@\n+#!/bin/sh\n+\n+test_description='magic pathspec tests using git-log'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\ttest_commit initial &&\n+\ttest_tick &&\n+\tgit commit --allow-empty -m empty &&\n+\tmkdir sub\n+'\n+\n+test_expect_failure 'git log :/ ambiguous with [ref]:/path' '\n+\ttest_must_fail git log :/ 2>error &&\n+\tgrep ambiguous error\n+'\n+\n+test_expect_failure 'git log :' '\n+\tgit log :\n+'\n+\n+test_expect_success 'git log HEAD -- :/' '\n+\tcat >expected <<EOF &&\n+24b24cf initial\n+EOF\n+\t(cd sub && git log --oneline HEAD -- :/ >../actual) &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git log HEAD -- :' '\n+\tcat >expected <<EOF &&\n+41d179c empty\n+24b24cf initial\n+EOF\n+\t(cd sub && git log --oneline HEAD -- : >../actual) &&\n+\ttest_cmp expected actual\n+'\n+\n+test_done\n-- \n1.7.4.74.g639db\n"},{"id":"167435","messageId":"7v7ha1t6o9.fsf@alter.siamese.dyndns.org","threadId":"27292","inReplyTo":"1304852906-29272-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] t3703, t4208: add test cases for magic pathspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-08T17:59:18Z","receivedAt":"2011-05-08T17:59:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> diff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh\n> new file mode 100755\n> index 0000000..3d8c6b8\n> --- /dev/null\n> +++ b/t/t3703-add-magic-pathspec.sh\n> @@ -0,0 +1,78 @@\n> +#!/bin/sh\n> +\n> +test_description='magic pathspec tests using git-add'\n> +\n> +. ./test-lib.sh\n> +\n> +test_expect_success 'setup' '\n> +\tmkdir sub anothersub &&\n> +\t: >sub/foo &&\n> +\t: >anothersub/foo\n> +'\n> +\n> +test_expect_failure 'colon alone magic can only used alone' '\n> +\ttest_must_fail git add -n sub/foo : &&\n> +\ttest_must_fail git add -n : sub/foo\n> +'\n\nI don't care too much about this case (it is a user error), but if you\npromise you will turn this expect-failure to expect-success in a follow-up\npatch, why not ;-)?\n\n> +cat >expected <<EOF\n> +add 'anothersub/foo'\n> +add 'expected'\n> +add 'sub/actual'\n> +add 'sub/foo'\n> +EOF\n> +\n> +test_expect_success 'add :' '\n> +\t(cd sub && git add -n : >actual) &&\n> +\ttest_cmp expected sub/actual\n> +'\n\nShouldn't\n\n\t$ git anycmd :\n\nbe equivalent to\n\n\t$ (cd $(git rev-parse --show-cdup)/. && git anycmd)\n\nfor any command?  I doubt this test is expecting the right outcome.\nShouldn't it result in \"Nothing specified, nothing added.\"?\n\n> +test_expect_success 'add :/' '\n> +\t(cd sub && git add -n :/ >actual) &&\n> +\ttest_cmp expected sub/actual\n> +'\n\nThis one is expecting the right thing.\n\n> +test_expect_success 'add :/non-existent' '\n> +\t(cd sub && test_must_fail git add -n :/non-existent)\n> +'\n\nJust being curious. What should the error message say?  Can we make it to\nsay \"fatal: pathspec 'non-ex' from root did not match any files\"?\n\n> +cat >expected <<EOF\n> +fatal: pathspec ':(icase)ha' did not match any files\n> +EOF\n\nWhen writing a literal, make it a habit to quote EOF to reduce mental load\non the reader, like this:\n\n\tcat >expected <<\\EOF\n        ...\n        EOF\n\nso that the reader does not have to scan for $var in the text to make\nsure.\n\n> +test_expect_failure 'show pathspecs exactly what are typed in' '\n> +\ttest_cmp expected error\n> +'\n\nWill this break under gettext-poison?\n\n> diff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh\n> new file mode 100755\n> index 0000000..b296a74\n> --- /dev/null\n> +++ b/t/t4208-log-magic-pathspec.sh\n> @@ -0,0 +1,40 @@\n> +#!/bin/sh\n> +\n> +test_description='magic pathspec tests using git-log'\n> +\n> +. ./test-lib.sh\n> +\n> +test_expect_success 'setup' '\n> +\ttest_commit initial &&\n> +\ttest_tick &&\n> +\tgit commit --allow-empty -m empty &&\n> +\tmkdir sub\n> +'\n> +\n> +test_expect_failure 'git log :/ ambiguous with [ref]:/path' '\n> +\ttest_must_fail git log :/ 2>error &&\n> +\tgrep ambiguous error\n> +'\n> +test_expect_failure 'git log :' '\n> +\tgit log :\n> +'\n\nThese two should expect exactly the same error, I think. ':', ':/' or\nanything magic will not satisify verify_filename(), and needs a\ndouble-dash before it.\n\nWe could improve the disambiguation heuristics so that when we do not have\na '--' on the command line:\n\n - make sure all the earlier ones are refs and they cannot be a path on\n   the filesystem (otherwise we need a disambiguator \"--\").\n\n - the first non-ref argument and everything that follows must be either a\n   ':' magic, a string with globbing character, or a path on the\n   filesystem, and none of them can be a ref.\n\nDo you want to take a stab at it?\n\n\n    \n"},{"id":"167492","messageId":"BANLkTikONPUVvAEw+fSDva8RUp-YSm-Nxw@mail.gmail.com","threadId":"27292","inReplyTo":"7v7ha1t6o9.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t3703, t4208: add test cases for magic pathspec","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-05-09T12:33:45Z","receivedAt":"2011-05-09T12:33:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2011/5/9 Junio C Hamano <gitster@pobox.com>:\n>> +test_expect_failure 'colon alone magic can only used alone' '\n>> +     test_must_fail git add -n sub/foo : &&\n>> +     test_must_fail git add -n : sub/foo\n>> +'\n>\n> I don't care too much about this case (it is a user error), but if you\n> promise you will turn this expect-failure to expect-success in a follow-up\n> patch, why not ;-)?\n\nfailed tests are (annoying enough) to be fixed, right? :)\n\n>> +cat >expected <<EOF\n>> +add 'anothersub/foo'\n>> +add 'expected'\n>> +add 'sub/actual'\n>> +add 'sub/foo'\n>> +EOF\n>> +\n>> +test_expect_success 'add :' '\n>> +     (cd sub && git add -n : >actual) &&\n>> +     test_cmp expected sub/actual\n>> +'\n>\n> Shouldn't\n>\n>        $ git anycmd :\n>\n> be equivalent to\n>\n>        $ (cd $(git rev-parse --show-cdup)/. && git anycmd)\n>\n> for any command?  I doubt this test is expecting the right outcome.\n> Shouldn't it result in \"Nothing specified, nothing added.\"?\n\nIt's gray area. Yes I'd rather see that behavior, but then a lot of\ncode needs to be audited. Perhaps we should delay introducing \":\"\nuntil get_pathspec() learns to modify argc. IOW die() for now when\nusers write \":\".\n\n>> +test_expect_success 'add :/non-existent' '\n>> +     (cd sub && test_must_fail git add -n :/non-existent)\n>> +'\n>\n> Just being curious. What should the error message say?  Can we make it to\n> say \"fatal: pathspec 'non-ex' from root did not match any files\"?\n\nMy opinion is in the next test. It should show exactly what users type\nin, ie. \"pathspec ':/non-existent' did not match any files\". \"'non-ex'\nfrom root\" is nice when there's only one magic. If users specify a few\nmore in one pathspec, the text may become too verbose.\n\n>> +test_expect_failure 'show pathspecs exactly what are typed in' '\n>> +     test_cmp expected error\n>> +'\n>\n> Will this break under gettext-poison?\n\nNever really known what that poison is. Will grep \":/non-existent\" instead.\n\n>> +test_expect_failure 'git log :/ ambiguous with [ref]:/path' '\n>> +     test_must_fail git log :/ 2>error &&\n>> +     grep ambiguous error\n>> +'\n>> +test_expect_failure 'git log :' '\n>> +     git log :\n>> +'\n>\n> These two should expect exactly the same error, I think. ':', ':/' or\n> anything magic will not satisify verify_filename(), and needs a\n> double-dash before it.\n\nYes. Error from the latter \"fatal: Path '' does not exist (neither on\ndisk nor in the index).\" makes me wonder, why does log accept a sha1\nsyntax that may resolve to non-commit object?\n\n> We could improve the disambiguation heuristics so that when we do not have\n> a '--' on the command line:\n>\n>  - make sure all the earlier ones are refs and they cannot be a path on\n>   the filesystem (otherwise we need a disambiguator \"--\").\n>\n>  - the first non-ref argument and everything that follows must be either a\n>   ':' magic, a string with globbing character, or a path on the\n>   filesystem, and none of them can be a ref.\n>\n> Do you want to take a stab at it?\n\nA bit busy these days. If you're interested, go ahead.\n-- \nDuy\n"},{"id":"167508","messageId":"7vvcxjq23o.fsf@alter.siamese.dyndns.org","threadId":"27292","inReplyTo":"BANLkTikONPUVvAEw+fSDva8RUp-YSm-Nxw@mail.gmail.com","subject":"Re: [PATCH] t3703, t4208: add test cases for magic pathspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-09T16:18:35Z","receivedAt":"2011-05-09T16:18:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n\n>> Shouldn't\n>>\n>>        $ git anycmd :\n>>\n>> be equivalent to\n>>\n>>        $ (cd $(git rev-parse --show-cdup)/. && git anycmd)\n>>\n>> for any command?  I doubt this test is expecting the right outcome.\n>> Shouldn't it result in \"Nothing specified, nothing added.\"?\n>\n> It's gray area.\n\nI do not see anything gray in it.\n\n\"git add :\" in subdirectory is simply broken because we have used \"No\nremaining command line argument means no pathspec\" when deciding to stop\nand say \"Nothing specified, nothing added\".  That was a sensible\nassumption back then, but it needs to be updated to take the new \"The\nremaining command line argument may say that there is no pathspec\" reality\ninto account.\n"},{"id":"167537","messageId":"7viptjo7f8.fsf@alter.siamese.dyndns.org","threadId":"27292","inReplyTo":"BANLkTikONPUVvAEw+fSDva8RUp-YSm-Nxw@mail.gmail.com","subject":"Re: [PATCH] t3703, t4208: add test cases for magic pathspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-09T22:06:35Z","receivedAt":"2011-05-09T22:06:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n\n> 2011/5/9 Junio C Hamano <gitster@pobox.com>:\n>>> +test_expect_failure 'colon alone magic can only used alone' '\n>>> +     test_must_fail git add -n sub/foo : &&\n>>> +     test_must_fail git add -n : sub/foo\n>>> +'\n>>\n>> I don't care too much about this case (it is a user error), but if you\n>> promise you will turn this expect-failure to expect-success in a follow-up\n>> patch, why not ;-)?\n>\n> failed tests are (annoying enough) to be fixed, right? :)\n\nDidn't I say it is not my itch already?\n"},{"id":"167570","messageId":"1305006678-4051-1-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1304852906-29272-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 0/9] magic pathspec updates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:09Z","receivedAt":"2011-05-10T05:51:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This is a series to update the magic pathspec topic, primarily the area\naround the empty ':' pathspec.\n\nThe failing tests from Duy's are mostly due to the fact that this round is\nnot converting the codebase fully and still use char **pathspec in places.\n\nAs get_pathspec() gives only a munged string for pattern matching, while\nlosing the original pathspec information such as up to which point in the\nresulting string came from the prefix (hence it must match literally even\nunder icase) or what the original string looked like, there is no way for\nthese tests, especially the ones to check failure mode and the information\nin the error report, to pass.\n\nAs NEEDSWORK comment in prefix_pathspec() says, all the callers need to be\nconverted to use \"struct pathspec\" interface, so that they can preserve\nthe original information for error reporting purposes (and also to pass\nto external subprocesses --- see how pathspec is used to spawn the \"add -i\"\nhelper for example).\n\nOther than that, I think the current code is probably more or less safe to\ndogfood with known rough edges.\n\nJunio C Hamano (8):\n  grep: use get_pathspec() correctly\n  get_pathspec(): an empty ':' pathspec should stand alone\n  count_pathspec(): return number of elements in pathspec\n  add \":\" is a pathspec that is too wide\n  git rm \":\" is like specifying nothing\n  clean \":\" is like specifying nothing\n  mv \":\" \":\" is like moving nothing from nowhere to nowhere\n  checkout \":\" is not giving any pathspec\n\nNguyễn Thái Ngọc Duy (1):\n  t3703, t4208: add test cases for magic pathspec\n\n Documentation/glossary-content.txt |    3 +\n builtin/add.c                      |    4 +-\n builtin/checkout.c                 |    9 +---\n builtin/clean.c                    |    1 +\n builtin/grep.c                     |    8 +---\n builtin/mv.c                       |    6 ++-\n builtin/rm.c                       |    4 +-\n cache.h                            |    3 +-\n setup.c                            |   18 ++++++++-\n t/t3703-add-magic-pathspec.sh      |   78 ++++++++++++++++++++++++++++++++++++\n t/t4208-log-magic-pathspec.sh      |   45 +++++++++++++++++++++\n 11 files changed, 160 insertions(+), 19 deletions(-)\n create mode 100755 t/t3703-add-magic-pathspec.sh\n create mode 100755 t/t4208-log-magic-pathspec.sh\n\n-- \n1.7.5.1.290.g1b565\n"},{"id":"167573","messageId":"1305006678-4051-2-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 1/9] grep: use get_pathspec() correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:10Z","receivedAt":"2011-05-10T05:51:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When there is no remaining string in argv, get_pathspec(prefix, argv)\nwill return a two-element array that has prefix as the first element,\nso there is no need to re-roll that logic in the code that uses\nget_pathspec().\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/grep.c |    8 +-------\n 1 files changed, 1 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 0bf8c01..222dd6d 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -956,13 +956,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t\tverify_filename(prefix, argv[j]);\n \t}\n \n-\tif (i < argc)\n-\t\tpaths = get_pathspec(prefix, argv + i);\n-\telse if (prefix) {\n-\t\tpaths = xcalloc(2, sizeof(const char *));\n-\t\tpaths[0] = prefix;\n-\t\tpaths[1] = NULL;\n-\t}\n+\tpaths = get_pathspec(prefix, argv + i);\n \tinit_pathspec(&pathspec, paths);\n \tpathspec.max_depth = opt.max_depth;\n \tpathspec.recursive = 1;\n-- \n1.7.5.1.290.g1b565\n"},{"id":"167571","messageId":"1305006678-4051-3-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 2/9] get_pathspec(): an empty ':' pathspec should stand alone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:11Z","receivedAt":"2011-05-10T05:51:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git cmd foo :\" is a user error; diagnose it as such.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n setup.c |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex 51e354c..c1be388 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -256,6 +256,7 @@ const char **get_pathspec(const char *prefix, const char **pathspec)\n \tconst char *entry = *pathspec;\n \tconst char **src, **dst;\n \tint prefixlen;\n+\tint has_root_widen = 0;\n \n \tif (!prefix && !entry)\n \t\treturn NULL;\n@@ -272,10 +273,15 @@ const char **get_pathspec(const char *prefix, const char **pathspec)\n \tdst = pathspec;\n \tprefixlen = prefix ? strlen(prefix) : 0;\n \twhile (*src) {\n-\t\t*(dst++) = prefix_pathspec(prefix, prefixlen, *src);\n+\t\tconst char *elem = prefix_pathspec(prefix, prefixlen, *src);\n+\t\t*(dst++) = elem;\n+\t\tif (!elem)\n+\t\t\thas_root_widen = 1;\n \t\tsrc++;\n \t}\n \t*dst = NULL;\n+\tif (has_root_widen && src != pathspec + 1)\n+\t\tdie(\"an empty ':' pathspec with other pathspecs\");\n \tif (!*pathspec)\n \t\treturn NULL;\n \treturn pathspec;\n-- \n1.7.5.1.290.g1b565\n"},{"id":"167572","messageId":"1305006678-4051-4-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 3/9] count_pathspec(): return number of elements in pathspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:12Z","receivedAt":"2011-05-10T05:51:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When fed a non-empty argv[], get_pathspec(prefix, argv) used to always\nreturn an array of string that has the same number of elements as argv[]\nhad, but with \":\" (work at toplevel without any path limit) magic pathspec\nit can return zero elements.  Passing the result from get_pathspec() to\nthis function will always give the correct number of pathspec elements.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n cache.h |    3 ++-\n setup.c |   10 ++++++++++\n 2 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex be6ce72..6170dce 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -425,7 +425,8 @@ extern void set_git_work_tree(const char *tree);\n \n #define ALTERNATE_DB_ENVIRONMENT \"GIT_ALTERNATE_OBJECT_DIRECTORIES\"\n \n-extern const char **get_pathspec(const char *prefix, const char **pathspec);\n+extern const char **get_pathspec(const char *prefix, const char **argv);\n+extern int count_pathspec(const char **pathspec);\n extern void setup_work_tree(void);\n extern const char *setup_git_directory_gently(int *);\n extern const char *setup_git_directory(void);\ndiff --git a/setup.c b/setup.c\nindex c1be388..cab9ddd 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -287,6 +287,16 @@ const char **get_pathspec(const char *prefix, const char **pathspec)\n \treturn pathspec;\n }\n \n+int count_pathspec(const char **pathspec)\n+{\n+\tint i;\n+\tif (!pathspec)\n+\t\treturn 0;\n+\tfor (i = 0; pathspec[i]; i++)\n+\t\t; /* just counting */\n+\treturn i;\n+}\n+\n /*\n  * Test if it looks like we're at a git directory.\n  * We want to see:\n-- \n1.7.5.1.290.g1b565\n"},{"id":"167574","messageId":"1305006678-4051-5-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 4/9] add \":\" is a pathspec that is too wide","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:13Z","receivedAt":"2011-05-10T05:51:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git cmd :\" should be exactly the same as \"git cmd\" run from the root\nlevel of the working tree.  \"git add\" without any pathspec should not\nadd anything.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/add.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex e127d5a..43a8aad 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -406,12 +406,12 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\t (!(addremove || take_worktree_changes)\n \t\t  ? ADD_CACHE_IGNORE_REMOVAL : 0));\n \n-\tif (require_pathspec && argc == 0) {\n+\tpathspec = validate_pathspec(argc, argv, prefix);\n+\tif (require_pathspec && (!argc || !pathspec)) {\n \t\tfprintf(stderr, \"Nothing specified, nothing added.\\n\");\n \t\tfprintf(stderr, \"Maybe you wanted to say 'git add .'?\\n\");\n \t\treturn 0;\n \t}\n-\tpathspec = validate_pathspec(argc, argv, prefix);\n \n \tif (read_cache() < 0)\n \t\tdie(\"index file corrupt\");\n-- \n1.7.5.1.290.g1b565\n"},{"id":"167575","messageId":"1305006678-4051-6-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 5/9] git rm \":\" is like specifying nothing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:14Z","receivedAt":"2011-05-10T05:51:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git cmd :\" should be exactly the same as running \"git cmd\" from the\nroot level of the working tree.  Do not decide solely on the value of\nargc (i.e. remaining parameters after options and revs are parsed) to\nsee if the user limited the operation with paths.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/rm.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex ff491d7..c31f915 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -162,11 +162,13 @@ int cmd_rm(int argc, const char **argv, const char *prefix)\n \t\tdie(\"index file corrupt\");\n \n \tpathspec = get_pathspec(prefix, argv);\n+\tif (!pathspec)\n+\t\tdie(\"removing nothing?\");\n \trefresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL);\n \n \tseen = NULL;\n \tfor (i = 0; pathspec[i] ; i++)\n-\t\t/* nothing */;\n+\t\t; /* nothing */\n \tseen = xcalloc(i, 1);\n \n \tfor (i = 0; i < active_nr; i++) {\n-- \n1.7.5.1.290.g1b565\n"},{"id":"167576","messageId":"1305006678-4051-7-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 6/9] clean \":\" is like specifying nothing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:15Z","receivedAt":"2011-05-10T05:51:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Adjust argc that is meant to correspond do the number of elements in\nthe pathspec array.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/clean.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/clean.c b/builtin/clean.c\nindex 4a312ab..686cd6b 100644\n--- a/builtin/clean.c\n+++ b/builtin/clean.c\n@@ -96,6 +96,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n \t\tadd_exclude(exclude_list.items[i].string, \"\", 0, dir.exclude_list);\n \n \tpathspec = get_pathspec(prefix, argv);\n+\targc = count_pathspec(pathspec);\n \n \tfill_directory(&dir, pathspec);\n \n-- \n1.7.5.1.290.g1b565\n"},{"id":"167577","messageId":"1305006678-4051-8-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 7/9] mv \":\" \":\" is like moving nothing from nowhere to nowhere","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:16Z","receivedAt":"2011-05-10T05:51:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Make sure the code can deal with get_pathspec() that returns nothing.\nStrictly speaking it may be a user error, but that is not an excuse\nto dump core.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/mv.c |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex 93e8995..38af9f0 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -77,8 +77,12 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\tdie(\"index file corrupt\");\n \n \tsource = copy_pathspec(prefix, argv, argc, 0);\n-\tmodes = xcalloc(argc, sizeof(enum update_mode));\n+\tif (!source)\n+\t\tdie(\"copying from nowhere?\");\n+\tmodes = xcalloc(count_pathspec(source), sizeof(enum update_mode));\n \tdest_path = copy_pathspec(prefix, argv + argc, 1, 0);\n+\tif (!dest_path)\n+\t\tdie(\"copying to nowhere?\");\n \n \tif (dest_path[0][0] == '\\0')\n \t\t/* special case: \".\" was normalized to \"\" */\n-- \n1.7.5.1.290.g1b565\n"},{"id":"167578","messageId":"1305006678-4051-9-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 8/9] checkout \":\" is not giving any pathspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:17Z","receivedAt":"2011-05-10T05:51:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git cmd :\" should be exactly the same as running \"git cmd\" from the\nroot level of the working tree.  Do not decide solely on the value of\nargc (i.e. remaining parameters after options and revs are parsed),\nbut make sure we actually do have pathspec to switch operation modes.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/checkout.c |    9 +++------\n 1 files changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 2bf02f2..fe46725 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -890,6 +890,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tchar *conflict_style = NULL;\n \tint patch_mode = 0;\n \tint dwim_new_local_branch = 1;\n+\tconst char **pathspec;\n \tstruct option options[] = {\n \t\tOPT__QUIET(&opts.quiet, \"suppress progress reporting\"),\n \t\tOPT_STRING('b', NULL, &opts.new_branch, \"branch\",\n@@ -1004,12 +1005,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tif (opts.track == BRANCH_TRACK_UNSPECIFIED)\n \t\topts.track = git_branch_track;\n \n-\tif (argc) {\n-\t\tconst char **pathspec = get_pathspec(prefix, argv);\n-\n-\t\tif (!pathspec)\n-\t\t\tdie(\"invalid path specification\");\n-\n+\tpathspec = get_pathspec(prefix, argv);\n+\tif (argc && pathspec) {\n \t\tif (patch_mode)\n \t\t\treturn interactive_checkout(new.name, pathspec, &opts);\n \n-- \n1.7.5.1.290.g1b565\n"},{"id":"167579","messageId":"1305006678-4051-10-git-send-email-gitster@pobox.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"[PATCH 9/9] t3703, t4208: add test cases for magic pathspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T05:51:18Z","receivedAt":"2011-05-10T05:51:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nWhile at it, also document \":\" syntax.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/glossary-content.txt |    3 +\n t/t3703-add-magic-pathspec.sh      |   78 ++++++++++++++++++++++++++++++++++++\n t/t4208-log-magic-pathspec.sh      |   45 +++++++++++++++++++++\n 3 files changed, 126 insertions(+), 0 deletions(-)\n create mode 100755 t/t3703-add-magic-pathspec.sh\n create mode 100755 t/t4208-log-magic-pathspec.sh\n\ndiff --git a/Documentation/glossary-content.txt b/Documentation/glossary-content.txt\nindex 0ca029b..0318024 100644\n--- a/Documentation/glossary-content.txt\n+++ b/Documentation/glossary-content.txt\n@@ -327,6 +327,9 @@ icase;;\n +\n It is envisioned that we will support more types of magic in later\n versions of git.\n++\n+A pathspec with only a colon means \"there is no pathspec\". This form\n+should not be combined with other pathspec.\n \n [[def_parent]]parent::\n \tA <<def_commit_object,commit object>> contains a (possibly empty) list\ndiff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh\nnew file mode 100755\nindex 0000000..9e6708a\n--- /dev/null\n+++ b/t/t3703-add-magic-pathspec.sh\n@@ -0,0 +1,78 @@\n+#!/bin/sh\n+\n+test_description='magic pathspec tests using git-add'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\tmkdir sub anothersub &&\n+\t: >sub/foo &&\n+\t: >anothersub/foo\n+'\n+\n+test_expect_success 'colon alone magic should only used alone' '\n+\ttest_must_fail git add -n sub/foo : &&\n+\ttest_must_fail git add -n : sub/foo\n+'\n+\n+test_expect_success 'add :' '\n+\t: >expected &&\n+\t(cd sub && git add -n : >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'add :/' \"\n+\tcat >expected <<-EOF &&\n+\tadd 'anothersub/foo'\n+\tadd 'expected'\n+\tadd 'sub/actual'\n+\tadd 'sub/foo'\n+\tEOF\n+\t(cd sub && git add -n :/ >actual) &&\n+\ttest_cmp expected sub/actual\n+\"\n+\n+cat >expected <<EOF\n+add 'anothersub/foo'\n+EOF\n+\n+test_expect_success 'add :/anothersub' '\n+\t(cd sub && git add -n :/anothersub >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'add :/non-existent' '\n+\t(cd sub && test_must_fail git add -n :/non-existent)\n+'\n+\n+cat >expected <<EOF\n+add 'sub/foo'\n+EOF\n+\n+test_expect_success 'add :(icase)foo' '\n+\t(cd sub && git add -n \":(icase)FoO\" >actual) &&\n+\ttest_cmp expected sub/actual\n+'\n+\n+test_expect_success 'a file with the same (long) magic name exists' '\n+\t: >\":(icase)ha\" &&\n+\ttest_must_fail git add -n \":(icase)ha\" 2>error &&\n+\tgit add -n \"./:(icase)ha\"\n+'\n+\n+cat >expected <<EOF\n+fatal: pathspec ':(icase)ha' did not match any files\n+EOF\n+\n+test_expect_failure 'show pathspecs exactly what are typed in' '\n+\ttest_cmp expected error\n+'\n+\n+test_expect_success 'a file with the same (short) magic name exists' '\n+\tmkdir \":\" &&\n+\t: >\":/bar\" &&\n+\ttest_must_fail git add -n :/bar &&\n+\tgit add -n \"./:/bar\"\n+'\n+\n+test_done\ndiff --git a/t/t4208-log-magic-pathspec.sh b/t/t4208-log-magic-pathspec.sh\nnew file mode 100755\nindex 0000000..ff7f485\n--- /dev/null\n+++ b/t/t4208-log-magic-pathspec.sh\n@@ -0,0 +1,45 @@\n+#!/bin/sh\n+\n+test_description='magic pathspec tests using git-log'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\ttest_commit initial &&\n+\ttest_tick &&\n+\tgit commit --allow-empty -m empty &&\n+\tmkdir sub\n+'\n+\n+test_expect_failure '\"git log :/\" should be ambiguous' '\n+\ttest_must_fail git log :/ 2>error &&\n+\tgrep ambiguous error\n+'\n+\n+test_expect_failure '\"git log :\" should be ambiguous' '\n+\ttest_must_fail git log : 2>error &&\n+\tgrep ambiguous error\n+'\n+\n+test_expect_success 'git log -- :' '\n+\tgit log -- :\n+'\n+\n+test_expect_success 'git log HEAD -- :/' '\n+\tcat >expected <<-EOF &&\n+\t24b24cf initial\n+\tEOF\n+\t(cd sub && git log --oneline HEAD -- :/ >../actual) &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git log HEAD -- :' '\n+\tcat >expected <<-EOF &&\n+\t41d179c empty\n+\t24b24cf initial\n+\tEOF\n+\t(cd sub && git log --oneline HEAD -- : >../actual) &&\n+\ttest_cmp expected actual\n+'\n+\n+test_done\n-- \n1.7.5.1.290.g1b565\n"},{"id":"167599","messageId":"BANLkTiniUzKM2P4PzqYaaVunN7-WjpkYmw@mail.gmail.com","threadId":"27292","inReplyTo":"1305006678-4051-4-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 3/9] count_pathspec(): return number of elements in pathspec","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-05-10T13:29:29Z","receivedAt":"2011-05-10T13:29:29Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, May 10, 2011 at 12:51 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> When fed a non-empty argv[], get_pathspec(prefix, argv) used to always\n> return an array of string that has the same number of elements as argv[]\n> had, but with \":\" (work at toplevel without any path limit) magic pathspec\n> it can return zero elements.  Passing the result from get_pathspec() to\n> this function will always give the correct number of pathspec elements.\n\nAnd use the new function in builtin/rm.c too? A good cleanup while\nyou're touching cmd_rm()..\n-- \nDuy\n"},{"id":"167600","messageId":"BANLkTinBv+aRfgdnFKM-=yedug+WtseXsQ@mail.gmail.com","threadId":"27292","inReplyTo":"1305006678-4051-8-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 7/9] mv \":\" \":\" is like moving nothing from nowhere to nowhere","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-05-10T13:30:37Z","receivedAt":"2011-05-10T13:30:37Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, May 10, 2011 at 12:51 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> diff --git a/builtin/mv.c b/builtin/mv.c\n> index 93e8995..38af9f0 100644\n> --- a/builtin/mv.c\n> +++ b/builtin/mv.c\n> @@ -77,8 +77,12 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n>                die(\"index file corrupt\");\n>\n>        source = copy_pathspec(prefix, argv, argc, 0);\n> -       modes = xcalloc(argc, sizeof(enum update_mode));\n> +       if (!source)\n> +               die(\"copying from nowhere?\");\n> +       modes = xcalloc(count_pathspec(source), sizeof(enum update_mode));\n>        dest_path = copy_pathspec(prefix, argv + argc, 1, 0);\n> +       if (!dest_path)\n> +               die(\"copying to nowhere?\");\n>\n\nThis command is interesting. Note to self: adding support for \"git mv\n'*.c' to/there\".\n\nI think we could take get_pathspec() out of copy_pathspec() and call\nit just once (in case get_pathspec() or its successor does fancy\nthings), something roughly like this\n\ndiff --git a/builtin/mv.c b/builtin/mv.c\nindex 40f33ca..a032789 100644\n--- a/builtin/mv.c\n+++ b/builtin/mv.c\n@@ -32,7 +32,7 @@ static const char **copy_pathspec(const char\n*prefix, const char **pathspec,\n \t\t\tresult[i] = base_name ? strdup(basename(it)) : it;\n \t\t}\n \t}\n-\treturn get_pathspec(prefix, result);\n+\treturn result;\n }\n\n static const char *add_slash(const char *path)\n@@ -60,7 +60,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOLEAN('k', NULL, &ignore_errors, \"skip move/rename errors\"),\n \t\tOPT_END(),\n \t};\n-\tconst char **source, **destination, **dest_path;\n+\tconst char **pathspec, **source, **destination, **dest_path;\n \tenum update_mode { BOTH = 0, WORKING_DIRECTORY, INDEX } *modes;\n \tstruct stat st;\n \tstruct string_list src_for_dst = STRING_LIST_INIT_NODUP;\n@@ -69,16 +69,20 @@ int cmd_mv(int argc, const char **argv, const char *prefix)\n\n \targc = parse_options(argc, argv, prefix, builtin_mv_options,\n \t\t\t     builtin_mv_usage, 0);\n-\tif (--argc < 1)\n+\n+\tpathspec = get_pathspec(prefix, argv);\n+\targc = count_pathspec(pathspec);\n+\n+\tif (--argc < 1 || !pathspec)\n \t\tusage_with_options(builtin_mv_usage, builtin_mv_options);\n\n \tnewfd = hold_locked_index(&lock_file, 1);\n \tif (read_cache() < 0)\n \t\tdie(_(\"index file corrupt\"));\n\n-\tsource = copy_pathspec(prefix, argv, argc, 0);\n+\tsource = copy_pathspec(prefix, pathspec, argc, 0);\n \tmodes = xcalloc(argc, sizeof(enum update_mode));\n-\tdest_path = copy_pathspec(prefix, argv + argc, 1, 0);\n+\tdest_path = copy_pathspec(prefix, pathspec + argc, 1, 0);\n\n \tif (dest_path[0][0] == '\\0')\n \t\t/* special case: \".\" was normalized to \"\" */\n-- \nDuy\n"},{"id":"167601","messageId":"BANLkTimLsNU0rLHRxxPmzFH_-1U5m3GoCw@mail.gmail.com","threadId":"27292","inReplyTo":"1305006678-4051-1-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 0/9] magic pathspec updates","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-05-10T13:47:04Z","receivedAt":"2011-05-10T13:47:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, May 10, 2011 at 12:51 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> This is a series to update the magic pathspec topic, primarily the area\n> around the empty ':' pathspec.\n\nI think you missed git-commit and git-reset. \"git commit --include :\"\nmay get past parse_and_validate_options() (ie. not dying) but later on\nin prepare_index(), there's no pathspec. I did not check very careful\nthough.\n\n> Other than that, I think the current code is probably more or less safe to\n> dogfood with known rough edges.\n\nAgreed.\n-- \nDuy\n"},{"id":"167603","messageId":"BANLkTi=OQtNh3fkd-xTSrrpo_FPpvH6isw@mail.gmail.com","threadId":"27292","inReplyTo":"1305006678-4051-7-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 6/9] clean \":\" is like specifying nothing","fromName":"Thiago Farina","fromEmail":"tfransosi@gmail.com","sentAt":"2011-05-10T15:14:59Z","receivedAt":"2011-05-10T15:14:59Z","isPatch":true,"sender":{"key":"tfransosi@gmail.com","avatar":"https://avatars.githubusercontent.com/u/970071?v=4"},"body":"On Tue, May 10, 2011 at 2:51 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Adjust argc that is meant to correspond do the number of elements in\ns/do/to ?\n\n> the pathspec array.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  builtin/clean.c |    1 +\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n>\n> diff --git a/builtin/clean.c b/builtin/clean.c\n> index 4a312ab..686cd6b 100644\n> --- a/builtin/clean.c\n> +++ b/builtin/clean.c\n> @@ -96,6 +96,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)\n>                add_exclude(exclude_list.items[i].string, \"\", 0, dir.exclude_list);\n>\n>        pathspec = get_pathspec(prefix, argv);\n> +       argc = count_pathspec(pathspec);\n>\n>        fill_directory(&dir, pathspec);\n>\n> --\n> 1.7.5.1.290.g1b565\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"167605","messageId":"7vvcxijxhi.fsf@alter.siamese.dyndns.org","threadId":"27292","inReplyTo":"BANLkTimLsNU0rLHRxxPmzFH_-1U5m3GoCw@mail.gmail.com","subject":"Re: [PATCH 0/9] magic pathspec updates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-10T17:07:05Z","receivedAt":"2011-05-10T17:07:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n\n> On Tue, May 10, 2011 at 12:51 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> This is a series to update the magic pathspec topic, primarily the area\n>> around the empty ':' pathspec.\n>\n> I think you missed git-commit and git-reset. \"git commit --include :\"\n> may get past parse_and_validate_options() (ie. not dying) but later on\n> in prepare_index(), there's no pathspec. I did not check very careful\n> though.\n>\n>> Other than that, I think the current code is probably more or less safe to\n>> dogfood with known rough edges.\n>\n> Agreed.\n\nAfter re-reading the series one more time (including the ones that are\nalready in next), I think teaching get_pathspec() about a lone \":\" was\nprobably a bad idea. The only reason we might want to say \"there is no\npathspec whatsoever\" is when a command wants to limit its operation to\nthe current subdirectory and it changes behaviour when run at the root\nlevel with and without pathspec (e.g. history simplification).\n\nNote that no such command exists in our vocabulary today, so you need\nto imagine \"git local-log\" that acts like \"git log\" but by default\nshows history simplified to explain only the subdirectory you are\ncurrently in, or something.\n\nSuch an application can easily notice that argv[] has only a lone \":\"\nleft and do the same thing it does when there is no pathspec, without\naffecting other (existing) users of get_pathspec().\n\nBut the thing is, we do not have such an application like \"local-log\"\nnow, we know we can easily support such commands when needed without\nteaching get_pathspec() about a lone \":\", and we can be sure that\nexisting commands that know get_pathspec() will never give them an\nempty pathspec if they feed a non-empty argv[] will not be broken by\nnot teaching get_pathspec() about a lone \":\".\n\nI am leaning toward ripping the lone \":\" support from the code in\n\"next\". I would also remove \":(icase)\" from \"next\". It was only meant\nto be a POC to show how far we could go only by futzing get_pathspec()\nfunction, and was never meant to be a serious implementation of the\nfeature. It should be re-done after we do deeper conversion and use\nthe \"struct pathspec\" interface not \"char **\" interface.\n"},{"id":"167667","messageId":"BANLkTi=dk9mHK+cncCz_vuYXPH9uyzcsGg@mail.gmail.com","threadId":"27292","inReplyTo":"7vvcxijxhi.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/9] magic pathspec updates","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-05-11T12:11:19Z","receivedAt":"2011-05-11T12:11:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, May 11, 2011 at 12:07 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Note that no such command exists in our vocabulary today, so you need\n> to imagine \"git local-log\" that acts like \"git log\" but by default\n> shows history simplified to explain only the subdirectory you are\n> currently in, or something.\n>\n> Such an application can easily notice that argv[] has only a lone \":\"\n> left and do the same thing it does when there is no pathspec, without\n> affecting other (existing) users of get_pathspec().\n\nHmm.. if \":\" (the semantics) is only used in few commands, perhaps an\noption would be better than the cryptic \":\".\n\n> I am leaning toward ripping the lone \":\" support from the code in\n> \"next\". I would also remove \":(icase)\" from \"next\". It was only meant\n> to be a POC to show how far we could go only by futzing get_pathspec()\n> function, and was never meant to be a serious implementation of the\n> feature. It should be re-done after we do deeper conversion and use\n> the \"struct pathspec\" interface not \"char **\" interface.\n\nOK. But reserve the lone \":\" syntax. It's precious. We may have a use\ncase for it some day.\n-- \nDuy\n"},{"id":"167713","messageId":"4DCB988D.6060908@viscovery.net","threadId":"27292","inReplyTo":"1305006678-4051-10-git-send-email-gitster@pobox.com","subject":"[PATCH jc/magic-pathspec] t3703: Skip tests using directory name \":\" on Windows","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-05-12T08:21:33Z","receivedAt":"2011-05-12T08:21:33Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <j6t@kdbg.org>\n\n\":\" is not allowed in file names on Windows. Detect this case and skip a\ntest if necessary.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\n t/t3703-add-magic-pathspec.sh |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh\nindex ce5585e..e508246 100755\n--- a/t/t3703-add-magic-pathspec.sh\n+++ b/t/t3703-add-magic-pathspec.sh\n@@ -44,8 +44,12 @@ test_expect_success 'a file with the same (long) magic name exists' '\n \tgit add -n \"./:(icase)ha\"\n '\n \n-test_expect_success 'a file with the same (short) magic name exists' '\n-\tmkdir \":\" &&\n+if mkdir \":\" 2>/dev/null\n+then\n+\ttest_set_prereq COLON_DIR\n+fi\n+\n+test_expect_success COLON_DIR 'a file with the same (short) magic name exists' '\n \t: >\":/bar\" &&\n \ttest_must_fail git add -n :/bar &&\n \tgit add -n \"./:/bar\"\n-- \n1.7.5.1.1644.g7f2ed\n"},{"id":"168947","messageId":"BANLkTimQ7H7SLbA=mREOSK_bQVN5Yo1oiQ@mail.gmail.com","threadId":"27292","inReplyTo":"1305006678-4051-10-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 9/9] t3703, t4208: add test cases for magic pathspec","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-05-29T18:29:23Z","receivedAt":"2011-05-29T18:29:23Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, May 10, 2011 at 07:51, Junio C Hamano <gitster@pobox.com> wrote:\n\n> +test_expect_success 'add :/' \"\n> +       cat >expected <<-EOF &&\n> +       add 'anothersub/foo'\n> +       add 'expected'\n> +       add 'sub/actual'\n> +       add 'sub/foo'\n> +       EOF\n> +       (cd sub && git add -n :/ >actual) &&\n> +       test_cmp expected sub/actual\n> +\"\n\nThis needs to use test_i18ncmp.\n"},{"id":"168954","messageId":"7v1uzhp7tj.fsf@alter.siamese.dyndns.org","threadId":"27292","inReplyTo":"BANLkTimQ7H7SLbA=mREOSK_bQVN5Yo1oiQ@mail.gmail.com","subject":"Re: [PATCH 9/9] t3703, t4208: add test cases for magic pathspec","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-29T20:31:36Z","receivedAt":"2011-05-29T20:31:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> On Tue, May 10, 2011 at 07:51, Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> +test_expect_success 'add :/' \"\n>> +       cat >expected <<-EOF &&\n>> +       add 'anothersub/foo'\n>> +       add 'expected'\n>> +       add 'sub/actual'\n>> +       add 'sub/foo'\n>> +       EOF\n>> +       (cd sub && git add -n :/ >actual) &&\n>> +       test_cmp expected sub/actual\n>> +\"\n>\n> This needs to use test_i18ncmp.\n\nI don't think so (at least not yet).\n\nDoesn't it come from read-cache.c::add_to_index()?\n"},{"id":"168955","messageId":"BANLkTi=1rjt4ezy+4A3nn4Xt44K5ifFo5Q@mail.gmail.com","threadId":"27292","inReplyTo":"7v1uzhp7tj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 9/9] t3703, t4208: add test cases for magic pathspec","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-05-29T20:36:31Z","receivedAt":"2011-05-29T20:36:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Sun, May 29, 2011 at 22:31, Junio C Hamano <gitster@pobox.com> wrote:\n\n>> This needs to use test_i18ncmp.\n>\n> I don't think so (at least not yet).\n>\n> Doesn't it come from read-cache.c::add_to_index()?\n\nDoh, this was because I had a local patch by Jonathan in my tree that\nI forgot was there. Sorry about the noise.\n"}]}