{"thread":{"id":"35544","subject":"git add -A fails in empty repository since 1.8.5","startedAt":"2013-12-18T08:06:09Z","lastAt":"2014-01-31T18:10:09Z","messageCount":18,"participants":["Thomas Ferris Nicolaisen","Antoine Pelisse","Duy Nguyen","Junio C Hamano","Matthieu Moy","Nguyễn Thái Ngọc Duy","Torsten Bögershausen","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"232140","messageId":"CAEcj5uWHpem+5os+3Mc_a42pk6f30i4UiV=LRPdXkoqiy1jQ_w@mail.gmail.com","threadId":"35544","inReplyTo":null,"subject":"git add -A fails in empty repository since 1.8.5","fromName":"Thomas Ferris Nicolaisen","fromEmail":"tfnico@gmail.com","sentAt":"2013-12-18T08:06:09Z","receivedAt":"2013-12-18T08:06:09Z","isPatch":false,"sender":{"key":"tfnico@gmail.com","avatar":"https://gravatar.com/avatar/628cf28a25ca4c596c7284562100f70f0ef908bcbfadd4da1eb3d48c23658d01?d=mp&s=160"},"body":"This was discussed on the Git user list recently [1].\n\n#in a repo with no files\n> git add -A\nfatal: pathspec '.' did not match any files\n\nThe same goes for git add . (and -u).\n\nWhereas I think some warning feedback is useful, we are curious\nwhether this is an intentional change or not.\n\n[1] https://groups.google.com/d/topic/git-users/Qs4YSPhTsqE/discussion\n"},{"id":"232141","messageId":"CALWbr2wXxSU4qD_Gj5P7aYxB39tEVBa-TDALVepuwZLh+RNU1Q@mail.gmail.com","threadId":"35544","inReplyTo":"CAEcj5uWHpem+5os+3Mc_a42pk6f30i4UiV=LRPdXkoqiy1jQ_w@mail.gmail.com","subject":"Re: git add -A fails in empty repository since 1.8.5","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-12-18T08:44:17Z","receivedAt":"2013-12-18T08:44:17Z","isPatch":false,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"FWIW, git-bisect points to 84b8b5d (that is $gmane/230349).\n\nOn Wed, Dec 18, 2013 at 9:06 AM, Thomas Ferris Nicolaisen\n<tfnico@gmail.com> wrote:\n> This was discussed on the Git user list recently [1].\n>\n> #in a repo with no files\n>> git add -A\n> fatal: pathspec '.' did not match any files\n>\n> The same goes for git add . (and -u).\n>\n> Whereas I think some warning feedback is useful, we are curious\n> whether this is an intentional change or not.\n>\n> [1] https://groups.google.com/d/topic/git-users/Qs4YSPhTsqE/discussion\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"},{"id":"232142","messageId":"CACsJy8DY7eZm7-P=azJF-jEiBKM_QPf_GXG3uzbuw5C1vq1Q5A@mail.gmail.com","threadId":"35544","inReplyTo":"CALWbr2wXxSU4qD_Gj5P7aYxB39tEVBa-TDALVepuwZLh+RNU1Q@mail.gmail.com","subject":"Re: git add -A fails in empty repository since 1.8.5","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-12-18T11:59:31Z","receivedAt":"2013-12-18T11:59:31Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Dec 18, 2013 at 3:44 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n> FWIW, git-bisect points to 84b8b5d (that is $gmane/230349).\n>\n> On Wed, Dec 18, 2013 at 9:06 AM, Thomas Ferris Nicolaisen\n> <tfnico@gmail.com> wrote:\n>> This was discussed on the Git user list recently [1].\n>>\n>> #in a repo with no files\n>>> git add -A\n>> fatal: pathspec '.' did not match any files\n>>\n>> The same goes for git add . (and -u).\n>>\n>> Whereas I think some warning feedback is useful, we are curious\n>> whether this is an intentional change or not.\n\nI was not aware of this case when I made the change. It's caused by\nthis change that removes pathspec.raw[i][0] check in builtin/add.c in\n84b8b5d .\n\n-               for (i = 0; pathspec.raw[i]; i++) {\n-                       if (!seen[i] && pathspec.raw[i][0]\n-                           && !file_exists(pathspec.raw[i])) {\n+               for (i = 0; i < pathspec.nr; i++) {\n+                       const char *path = pathspec.items[i].match;\n+                       if (!seen[i] && !file_exists(path)) {\n\nAdding it back requires some thinking because \"path\" in the new code\ncould be something magic.. and the new behavior makes sense, so I'm\ninclined to keep it as is, unless people have other opinions.\n\n>>\n>> [1] https://groups.google.com/d/topic/git-users/Qs4YSPhTsqE/discussion\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\n\n-- \nDuy\n"},{"id":"232182","messageId":"xmqqioumhtvp.fsf@gitster.dls.corp.google.com","threadId":"35544","inReplyTo":"CACsJy8DY7eZm7-P=azJF-jEiBKM_QPf_GXG3uzbuw5C1vq1Q5A@mail.gmail.com","subject":"Re: git add -A fails in empty repository since 1.8.5","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-18T18:54:50Z","receivedAt":"2013-12-18T18:54:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Wed, Dec 18, 2013 at 3:44 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n>> FWIW, git-bisect points to 84b8b5d (that is $gmane/230349).\n>>\n>> On Wed, Dec 18, 2013 at 9:06 AM, Thomas Ferris Nicolaisen\n>> <tfnico@gmail.com> wrote:\n>>> This was discussed on the Git user list recently [1].\n>>>\n>>> #in a repo with no files\n>>>> git add -A\n>>> fatal: pathspec '.' did not match any files\n>>>\n>>> The same goes for git add . (and -u).\n>>>\n>>> Whereas I think some warning feedback is useful, we are curious\n>>> whether this is an intentional change or not.\n\nThe logic to produce that error message is primarily to catch a typo\nlike:\n\n\t$ git add Nakefile\n\nwhen the user meant to say Makefile.\n\nIt could be argued that a \"git add [<any option>] .\", with an\nexplicit \".\" given by the end-user, that is run in an empty\ndirectory may be an error worth reporting.  Just like it is likely\nfor the user to have wanted to add some other file when he typed\nNakefile and it is not good to silently decide \"ah, nothing matches\nthe pathspec, so not adding anything is the right thing to do\" in\nsuch a case, it is plausible that the user thought that he was in\nsome other directory he wanted to add its contents to the index when\nhe gave us the explicit \".\", while he was in fact in a wrong\ndirectory, and it is not good to silently decide \"nothing there to\nadd so I won't do anything\" without any indication of an error.\n\nWe should *not* error out \"git add [<any option>]\" without any\nend-user pathspecs, especially with that error message, on the other\nhand.\n\n> I was not aware of this case when I made the change. It's caused by\n> this change that removes pathspec.raw[i][0] check in builtin/add.c in\n> 84b8b5d .\n>\n> -               for (i = 0; pathspec.raw[i]; i++) {\n> -                       if (!seen[i] && pathspec.raw[i][0]\n> -                           && !file_exists(pathspec.raw[i])) {\n> +               for (i = 0; i < pathspec.nr; i++) {\n> +                       const char *path = pathspec.items[i].match;\n> +                       if (!seen[i] && !file_exists(path)) {\n>\n> Adding it back requires some thinking because \"path\" in the new code\n> could be something magic.. and the new behavior makes sense, so I'm\n> inclined to keep it as is, unless people have other opinions.\n>\n>>>\n>>> [1] https://groups.google.com/d/topic/git-users/Qs4YSPhTsqE/discussion\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"},{"id":"232185","messageId":"vpqvbymarnw.fsf@anie.imag.fr","threadId":"35544","inReplyTo":"xmqqioumhtvp.fsf@gitster.dls.corp.google.com","subject":"Re: git add -A fails in empty repository since 1.8.5","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-12-18T19:24:35Z","receivedAt":"2013-12-18T19:24:35Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> It could be argued that a \"git add [<any option>] .\", with an\n> explicit \".\" given by the end-user, that is run in an empty\n> directory may be an error worth reporting.\n\nBut what we have right now is really weird:\n\n# setup repo with one empty dir:\n$ rm -fr test\n$ git init test\nInitialized empty Git repository in /tmp/test/.git/\n$ cd test\n$ mkdir foo\n\n$ git add .\nfatal: pathspec '.' did not match any files\n\n=> The one we're discussing.\n\n$ git add foo\n\n=> No error when an empty directory other than . is given.\n\n$ cd foo\n$ git add .\n\n=> No error either for \"git add .\" when not at the root of the repo.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"232189","messageId":"xmqq1u1ahr13.fsf@gitster.dls.corp.google.com","threadId":"35544","inReplyTo":"vpqvbymarnw.fsf@anie.imag.fr","subject":"Re: git add -A fails in empty repository since 1.8.5","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-18T19:56:24Z","receivedAt":"2013-12-18T19:56:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> It could be argued that a \"git add [<any option>] .\", with an\n>> explicit \".\" given by the end-user, that is run in an empty\n>> directory may be an error worth reporting.\n>\n> But what we have right now is really weird:\n\nI know.  That is why I said \"It _could_ be argued\".\n"},{"id":"232199","messageId":"xmqqhaa5ho7x.fsf@gitster.dls.corp.google.com","threadId":"35544","inReplyTo":"CACsJy8DY7eZm7-P=azJF-jEiBKM_QPf_GXG3uzbuw5C1vq1Q5A@mail.gmail.com","subject":"Re: git add -A fails in empty repository since 1.8.5","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-18T20:57:06Z","receivedAt":"2013-12-18T20:57:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Wed, Dec 18, 2013 at 3:44 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n>> FWIW, git-bisect points to 84b8b5d (that is $gmane/230349).\n>>\n>> On Wed, Dec 18, 2013 at 9:06 AM, Thomas Ferris Nicolaisen\n>> <tfnico@gmail.com> wrote:\n>>> This was discussed on the Git user list recently [1].\n>>>\n>>> #in a repo with no files\n>>>> git add -A\n>>> fatal: pathspec '.' did not match any files\n>>>\n>>> The same goes for git add . (and -u).\n>>>\n>>> Whereas I think some warning feedback is useful, we are curious\n>>> whether this is an intentional change or not.\n>\n> I was not aware of this case when I made the change. It's caused by\n> this change that removes pathspec.raw[i][0] check in builtin/add.c in\n> 84b8b5d .\n>\n> -               for (i = 0; pathspec.raw[i]; i++) {\n> -                       if (!seen[i] && pathspec.raw[i][0]\n> -                           && !file_exists(pathspec.raw[i])) {\n> +               for (i = 0; i < pathspec.nr; i++) {\n> +                       const char *path = pathspec.items[i].match;\n> +                       if (!seen[i] && !file_exists(path)) {\n\nIsn't that pathspec.raw[i][0] check merely an attempt to work around\nthe combination of\n\n (1) \"the current directory\" pathspec \".\" is sanitized down to an\n     empty string by the pathspec code; and\n\n (2) even though file_exists() is willing to say \"yes\" to a non-file\n     (namely, a directory), it is not prepared to take an empty\n     string resulting from (1) to mean \"the directory .\".\n\n> Adding it back requires some thinking because \"path\" in the new code\n> could be something magic..\n\nEhh, why?  Shouldn't \"something magic\" that did _not_ match\n(i.e. not in seen[]) diagnosed as such?\n\nI am wondering why we even need !file_exists(path) check there in\nthe first place.  We run fill_directory() and then let\nprune_directory() report which pathspec did not have any match via\nthe seen[] array.  We also match pathspec against the index to see\nif there are pathspec that does not match anything.  So at that\npoint of the codeflow, we ought to be able to make sure that seen[]\nis the _only_ thing we need to consult to see if there are any\npathspec elements that did not match.\n\nStepping back even further, I wonder if this \"yes, I found a\nmatching entity and know this is not an end-user typo\" bit actually\nshould be _in_ \"struct pathspec\".  Traditionally we implemented that\nbit as a separate seen[] array parallel to \"const char **pathspec\"\narray, but that was merely because we only had the list of strings.\nNow we express a pathspec as a list of \"struct pathspec\" elements,\nI think seen[] can and should become part of the pathspec.  Am I\nmissing something?\n\n\n> and the new behavior makes sense, so I'm\n> inclined to keep it as is, unless people have other opinions.\n>\n>>>\n>>> [1] https://groups.google.com/d/topic/git-users/Qs4YSPhTsqE/discussion\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"},{"id":"232223","messageId":"CACsJy8BYDYUvpNwR4iSg+hiJGyZF2u75-y9XHg_qwJ4Xrxa+DA@mail.gmail.com","threadId":"35544","inReplyTo":"xmqqhaa5ho7x.fsf@gitster.dls.corp.google.com","subject":"Re: git add -A fails in empty repository since 1.8.5","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-12-19T00:49:57Z","receivedAt":"2013-12-19T00:49:57Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Dec 19, 2013 at 3:57 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Duy Nguyen <pclouds@gmail.com> writes:\n>\n>> On Wed, Dec 18, 2013 at 3:44 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n>>> FWIW, git-bisect points to 84b8b5d (that is $gmane/230349).\n>>>\n>>> On Wed, Dec 18, 2013 at 9:06 AM, Thomas Ferris Nicolaisen\n>>> <tfnico@gmail.com> wrote:\n>>>> This was discussed on the Git user list recently [1].\n>>>>\n>>>> #in a repo with no files\n>>>>> git add -A\n>>>> fatal: pathspec '.' did not match any files\n>>>>\n>>>> The same goes for git add . (and -u).\n>>>>\n>>>> Whereas I think some warning feedback is useful, we are curious\n>>>> whether this is an intentional change or not.\n>>\n>> I was not aware of this case when I made the change. It's caused by\n>> this change that removes pathspec.raw[i][0] check in builtin/add.c in\n>> 84b8b5d .\n>>\n>> -               for (i = 0; pathspec.raw[i]; i++) {\n>> -                       if (!seen[i] && pathspec.raw[i][0]\n>> -                           && !file_exists(pathspec.raw[i])) {\n>> +               for (i = 0; i < pathspec.nr; i++) {\n>> +                       const char *path = pathspec.items[i].match;\n>> +                       if (!seen[i] && !file_exists(path)) {\n>\n> Isn't that pathspec.raw[i][0] check merely an attempt to work around\n> the combination of\n>\n>  (1) \"the current directory\" pathspec \".\" is sanitized down to an\n>      empty string by the pathspec code; and\n>\n>  (2) even though file_exists() is willing to say \"yes\" to a non-file\n>      (namely, a directory), it is not prepared to take an empty\n>      string resulting from (1) to mean \"the directory .\".\n\nYeah, and it was added so intentionally in 07d7bed (add: don't\ncomplain when adding empty project root - 2009-04-28). So this is a\nregression.\n\n>> Adding it back requires some thinking because \"path\" in the new code\n>> could be something magic..\n>\n> Ehh, why?  Shouldn't \"something magic\" that did _not_ match\n> (i.e. not in seen[]) diagnosed as such?\n>\n> I am wondering why we even need !file_exists(path) check there in\n> the first place.  We run fill_directory() and then let\n> prune_directory() report which pathspec did not have any match via\n> the seen[] array.  We also match pathspec against the index to see\n> if there are pathspec that does not match anything.  So at that\n> point of the codeflow, we ought to be able to make sure that seen[]\n> is the _only_ thing we need to consult to see if there are any\n> pathspec elements that did not match.\n\nSee e96980e (builtin-add: simplify (and increase accuracy of) exclude\nhandling - 2007-06-12). It has something to do with directory check\noriginally, then we don't care about S_ISDIR() any more and turn it to\nfile_exists(). Maybe it's safe to remove it now. Need to check\nfill_directory() again..\n\n> Stepping back even further, I wonder if this \"yes, I found a\n> matching entity and know this is not an end-user typo\" bit actually\n> should be _in_ \"struct pathspec\".  Traditionally we implemented that\n> bit as a separate seen[] array parallel to \"const char **pathspec\"\n> array, but that was merely because we only had the list of strings.\n> Now we express a pathspec as a list of \"struct pathspec\" elements,\n> I think seen[] can and should become part of the pathspec.  Am I\n> missing something?\n\nYes it probably better belongs to struct pathspec. Turning it into 1\nflag would simplify seen[] memory management too.\n\n>\n>\n>> and the new behavior makes sense, so I'm\n>> inclined to keep it as is, unless people have other opinions.\n>>\n>>>>\n>>>> [1] https://groups.google.com/d/topic/git-users/Qs4YSPhTsqE/discussion\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\n\n-- \nDuy\n"},{"id":"232360","messageId":"1387789361-29036-1-git-send-email-pclouds@gmail.com","threadId":"35544","inReplyTo":"CAEcj5uWHpem+5os+3Mc_a42pk6f30i4UiV=LRPdXkoqiy1jQ_w@mail.gmail.com","subject":"[PATCH] add: don't complain when adding empty project root","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2013-12-23T09:02:41Z","receivedAt":"2013-12-23T09:02:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This behavior was added in 07d7bed (add: don't complain when adding\nempty project root - 2009-04-28) then broken by 84b8b5d (remove\nmatch_pathspec() in favor of match_pathspec_depth() -\n2013-07-14). Reinstate it.\n\nNoticed-by: Thomas Ferris Nicolaisen <tfnico@gmail.com>\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/add.c  | 2 +-\n t/t3700-add.sh | 4 ++++\n 2 files changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 226f758..fbd3f3a 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -544,7 +544,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \n \t\tfor (i = 0; i < pathspec.nr; i++) {\n \t\t\tconst char *path = pathspec.items[i].match;\n-\t\t\tif (!seen[i] &&\n+\t\t\tif (!seen[i] && pathspec.items[i].match[0] &&\n \t\t\t    ((pathspec.items[i].magic &\n \t\t\t      (PATHSPEC_GLOB | PATHSPEC_ICASE)) ||\n \t\t\t     !file_exists(path))) {\ndiff --git a/t/t3700-add.sh b/t/t3700-add.sh\nindex aab86e8..1535d8f 100755\n--- a/t/t3700-add.sh\n+++ b/t/t3700-add.sh\n@@ -307,4 +307,8 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out\n \ttest_i18ncmp expect.err actual.err\n '\n \n+test_expect_success 'git add -A on empty repo does not error out' '\n+\tgit init empty && ( cd empty && git add -A . )\n+'\n+\n test_done\n-- \n1.8.5.2.240.g8478abd\n"},{"id":"232363","messageId":"52B87759.2090901@web.de","threadId":"35544","inReplyTo":"1387789361-29036-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2013-12-23T17:48:09Z","receivedAt":"2013-12-23T17:48:09Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2013-12-23 10.02, Nguyễn Thái Ngọc Duy wrote:\n> This behavior was added in 07d7bed (add: don't complain when adding\n> empty project root - 2009-04-28) then broken by 84b8b5d (remove\n> match_pathspec() in favor of match_pathspec_depth() -\n> 2013-07-14). Reinstate it.\n> \n> Noticed-by: Thomas Ferris Nicolaisen <tfnico@gmail.com>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  builtin/add.c  | 2 +-\n>  t/t3700-add.sh | 4 ++++\n>  2 files changed, 5 insertions(+), 1 deletion(-)\n> \n> diff --git a/builtin/add.c b/builtin/add.c\n> index 226f758..fbd3f3a 100644\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -544,7 +544,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n>  \n>  \t\tfor (i = 0; i < pathspec.nr; i++) {\n>  \t\t\tconst char *path = pathspec.items[i].match;\n> -\t\t\tif (!seen[i] &&\n> +\t\t\tif (!seen[i] && pathspec.items[i].match[0] &&\n>  \t\t\t    ((pathspec.items[i].magic &\n>  \t\t\t      (PATHSPEC_GLOB | PATHSPEC_ICASE)) ||\n>  \t\t\t     !file_exists(path))) {\n> diff --git a/t/t3700-add.sh b/t/t3700-add.sh\n> index aab86e8..1535d8f 100755\n> --- a/t/t3700-add.sh\n> +++ b/t/t3700-add.sh\n> @@ -307,4 +307,8 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out\n>  \ttest_i18ncmp expect.err actual.err\n>  '\n>  \n> +test_expect_success 'git add -A on empty repo does not error out' '\n> +\tgit init empty && ( cd empty && git add -A . )\n> +'\n> +\n>  test_done\n> \nI am (a little bit) confused.\n\nThis is what git does:\n rm -rf test && mkdir test && cd test && git init && touch A && mkdir D && cd D && touch B && git add . && git status\nInitialized empty Git repository in /Users/tb/test/test/.git/\nOn branch master\n\nInitial commit\n\nChanges to be committed:\n  (use \"git rm --cached <file>...\" to unstage)\n\n        new file:   B\n\nUntracked files:\n  (use \"git add <file>...\" to include in what will be committed)\n\n        ../A\n----------------\nAnd the behaviour is in line with\nhttps://www.kernel.org/pub/software/scm/git/docs/git-add.html\n\n\".\" stands for the current directory somewhere in the worktree,\nnot only the \"project root\".\n-----------------\n\nCould it make sense to mention that replace\n[PATCH] add: don't complain when adding empty project root\nwith\n[PATCH] add: don't complain when adding empty directory.\n\n(and similar in the commit message)\n/Torsten\n"},{"id":"232365","messageId":"CACsJy8A7j_ERqH_TDuKDdssaLFCvM5yVT4eUjTqkN_qW4iXuGA@mail.gmail.com","threadId":"35544","inReplyTo":"52B87759.2090901@web.de","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-12-23T23:46:06Z","receivedAt":"2013-12-23T23:46:06Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Dec 24, 2013 at 12:48 AM, Torsten Bögershausen <tboegi@web.de> wrote:\n>> +test_expect_success 'git add -A on empty repo does not error out' '\n>> +     git init empty && ( cd empty && git add -A . )\n>> +'\n>> +\n>>  test_done\n>>\n> I am (a little bit) confused.\n>\n> This is what git does:\n>  rm -rf test && mkdir test && cd test && git init && touch A && mkdir D && cd D && touch B && git add . && git status\n> Initialized empty Git repository in /Users/tb/test/test/.git/\n> On branch master\n>\n> Initial commit\n>\n> Changes to be committed:\n>   (use \"git rm --cached <file>...\" to unstage)\n>\n>         new file:   B\n>\n> Untracked files:\n>   (use \"git add <file>...\" to include in what will be committed)\n>\n>         ../A\n> ----------------\n> And the behaviour is in line with\n> https://www.kernel.org/pub/software/scm/git/docs/git-add.html\n>\n> \".\" stands for the current directory somewhere in the worktree,\n> not only the \"project root\".\n\nYes, except in this case \".\" is project root because current dir is. I\ncould have done \"git add -A\" (without the dot) like reported, but that\nwill be deprecated soon. Another way to make it clear about project\nroot is use \"git add -A :/\". I'll send an update if it makes it\nclearer.\n\n> -----------------\n>\n> Could it make sense to mention that replace\n> [PATCH] add: don't complain when adding empty project root\n> with\n> [PATCH] add: don't complain when adding empty directory.\n\nWe don't complain about adding an empty directory before or after this patch.\n\n>\n> (and similar in the commit message)\n> /Torsten\n>\n\n\n\n-- \nDuy\n"},{"id":"232379","messageId":"52BA0110.4050003@web.de","threadId":"35544","inReplyTo":"CACsJy8A7j_ERqH_TDuKDdssaLFCvM5yVT4eUjTqkN_qW4iXuGA@mail.gmail.com","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2013-12-24T21:48:00Z","receivedAt":"2013-12-24T21:48:00Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 2013-12-24 00.46, Duy Nguyen wrote:\n>\n[snip]\n> We don't complain about adding an empty directory before or after this patch.\nOk, thanks for the explanation.\n\nI think that\nhttps://www.kernel.org/pub/software/scm/git/docs/git-add.html\ncould deserve an update.\n\nMy understanding is that <filepattern> is related to $GIT_DIR,\nbut \".\" is the current directory. \n\nI will be happy to write a patch,\n(or to review one, whatever comes first)\n/Torsten\n \n"},{"id":"232380","messageId":"CACsJy8ApEBq+G+swpBPPJwL1E94x-P+e+V_jYknG+rXybLxPgQ@mail.gmail.com","threadId":"35544","inReplyTo":"52BA0110.4050003@web.de","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-12-24T23:49:05Z","receivedAt":"2013-12-24T23:49:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Dec 25, 2013 at 4:48 AM, Torsten Bögershausen <tboegi@web.de> wrote:\n> On 2013-12-24 00.46, Duy Nguyen wrote:\n>>\n> [snip]\n>> We don't complain about adding an empty directory before or after this patch.\n> Ok, thanks for the explanation.\n>\n> I think that\n> https://www.kernel.org/pub/software/scm/git/docs/git-add.html\n> could deserve an update.\n>\n> My understanding is that <filepattern> is related to $GIT_DIR,\n> but \".\" is the current directory.\n>\n> I will be happy to write a patch,\n> (or to review one, whatever comes first)\n> /Torsten\n\nfilepattern is related to current directory too (e.g. \"*.sh\" from \"t\"\nwon't cover git-rebase.sh, \":/*.sh\" does). Yes a patch to update\ngit-add.txt to use the term \"pathspec\" instead of \"filepattern\" would\nbe nice. A pointer to pathspec glossary could help discover\ncase-insensitive matching, negative matching..\n-- \nDuy\n"},{"id":"232409","messageId":"20131226172542.GS20443@google.com","threadId":"35544","inReplyTo":"1387789361-29036-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-12-26T17:25:42Z","receivedAt":"2013-12-26T17:25:42Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nNguyễn Thái Ngọc Duy wrote:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nThanks.\n\n[...]\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -544,7 +544,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n>  \n>  \t\tfor (i = 0; i < pathspec.nr; i++) {\n>  \t\t\tconst char *path = pathspec.items[i].match;\n> -\t\t\tif (!seen[i] &&\n> +\t\t\tif (!seen[i] && pathspec.items[i].match[0] &&\n>  \t\t\t    ((pathspec.items[i].magic &\n>  \t\t\t      (PATHSPEC_GLOB | PATHSPEC_ICASE)) ||\n>  \t\t\t     !file_exists(path))) {\n\nNit: in this loop there's already the synonym 'path' for item.match,\nso perhaps\n\n\t\t\tif (!seen[i] && path[0] && ...)\n\nwould be clearer.\n\nShould \"git add --refresh .\" get the same treatment?\n\n> --- a/t/t3700-add.sh\n> +++ b/t/t3700-add.sh\n> @@ -307,4 +307,8 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out\n>  \ttest_i18ncmp expect.err actual.err\n>  '\n>  \n> +test_expect_success 'git add -A on empty repo does not error out' '\n> +\tgit init empty && ( cd empty && git add -A . )\n> +'\n\nAdding a test at the end like this means the tests come in chronological\norder instead of logical order and simultaneous patches to the same\ntest script become more likely to conflict.\n\nHow about something like the following, for squashing in?\n\nWith or without the tweaks below,\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n\ndiff --git i/builtin/add.c w/builtin/add.c\nindex fbd3f3a..d7e3e44 100644\n--- i/builtin/add.c\n+++ w/builtin/add.c\n@@ -544,7 +544,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \n \t\tfor (i = 0; i < pathspec.nr; i++) {\n \t\t\tconst char *path = pathspec.items[i].match;\n-\t\t\tif (!seen[i] && pathspec.items[i].match[0] &&\n+\t\t\tif (!seen[i] && path[0] &&\n \t\t\t    ((pathspec.items[i].magic &\n \t\t\t      (PATHSPEC_GLOB | PATHSPEC_ICASE)) ||\n \t\t\t     !file_exists(path))) {\ndiff --git i/t/t3700-add.sh w/t/t3700-add.sh\nindex 1535d8f..fe274e2 100755\n--- i/t/t3700-add.sh\n+++ w/t/t3700-add.sh\n@@ -272,6 +272,25 @@ test_expect_success '\"add non-existent\" should fail' '\n \t! (git ls-files | grep \"non-existent\")\n '\n \n+test_expect_success 'git add -A on empty repo does not error out' '\n+\trm -fr empty &&\n+\tgit init empty &&\n+\t(\n+\t\tcd empty &&\n+\t\tgit add -A . &&\n+\t\tgit add -A\n+\t)\n+'\n+\n+test_expect_success '\"git add .\" in empty repo' '\n+\trm -fr empty &&\n+\tgit init empty &&\n+\t(\n+\t\tcd empty &&\n+\t\tgit add .\n+\t)\n+'\n+\n test_expect_success 'git add --dry-run of existing changed file' \"\n \techo new >>track-this &&\n \tgit add --dry-run track-this >actual 2>&1 &&\n@@ -307,8 +326,4 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out\n \ttest_i18ncmp expect.err actual.err\n '\n \n-test_expect_success 'git add -A on empty repo does not error out' '\n-\tgit init empty && ( cd empty && git add -A . )\n-'\n-\n test_done\n"},{"id":"232410","messageId":"xmqqtxdvcuj0.fsf@gitster.dls.corp.google.com","threadId":"35544","inReplyTo":"20131226172542.GS20443@google.com","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-26T18:54:43Z","receivedAt":"2013-12-26T18:54:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> How about something like the following, for squashing in?\n>\n> With or without the tweaks below,\n> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n\nThanks, both.\n\nRegarding \"git add --refresh\" (no other arguments), it would say\n\"Nothing specified, nothing added.\", and that is unrelated to the\nbreakage reported and fixed in this thread, I think.  It is the same\nmessage \"git add\" (no other arguments) gives, which I think is a\nmistake.  \"git add --refresh\" is like \"git add -u\" in that the\naffected paths are determined by the index, and running these\ncommands while your index is still empty can just be a silent no-op.\n"},{"id":"232412","messageId":"xmqqlhz7ct5b.fsf@gitster.dls.corp.google.com","threadId":"35544","inReplyTo":"xmqqtxdvcuj0.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-12-26T19:24:32Z","receivedAt":"2013-12-26T19:24:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Regarding \"git add --refresh\" (no other arguments), it would say\n> \"Nothing specified, nothing added.\", and that is unrelated to the\n> breakage reported and fixed in this thread, I think.  It is the same\n> message \"git add\" (no other arguments) gives, which I think is a\n> mistake.  \"git add --refresh\" is like \"git add -u\" in that the\n> affected paths are determined by the index, and running these\n> commands while your index is still empty can just be a silent no-op.\n\nSomething like this...\n\n builtin/add.c | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex d7e3e44..84e8a3e 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -483,8 +483,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \t\t (implicit_dot ? ADD_CACHE_IMPLICIT_DOT : 0);\n \n \tif (require_pathspec && argc == 0) {\n-\t\tfprintf(stderr, _(\"Nothing specified, nothing added.\\n\"));\n-\t\tfprintf(stderr, _(\"Maybe you wanted to say 'git add .'?\\n\"));\n+\t\tif (!refresh_only) {\n+\t\t\tfprintf(stderr, _(\"Nothing specified, nothing added.\\n\"));\n+\t\t\tfprintf(stderr, _(\"Maybe you wanted to say 'git add .'?\\n\"));\n+\t\t}\n \t\treturn 0;\n \t}\n \n"},{"id":"233944","messageId":"52EA3A07.2090203@web.de","threadId":"35544","inReplyTo":"CACsJy8ApEBq+G+swpBPPJwL1E94x-P+e+V_jYknG+rXybLxPgQ@mail.gmail.com","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2014-01-30T11:39:51Z","receivedAt":"2014-01-30T11:39:51Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"[]\n> filepattern is related to current directory too (e.g. \"*.sh\" from \"t\"\n> won't cover git-rebase.sh, \":/*.sh\" does). Yes a patch to update\n> git-add.txt to use the term \"pathspec\" instead of \"filepattern\" would\n> be nice. A pointer to pathspec glossary could help discover\n> case-insensitive matching, negative matching..\n\n\nTo somewhat end this thread: \nI haven't been able to find a patch that really improves the documentation,\nbecause \"Documentation/git-add.txt\" has already been updated:\n\ncommit 30784198b766b19a639c199e4365f2a805fc08c6\nAuthor: Junio C Hamano <gitster@pobox.com>\nDate:   Thu Feb 14 15:51:43 2013 -0800\n\n    Documentation/git-add: kill remaining <filepattern>\n--------------------\n\nAnd all changes are here:\nhttp://git-htmldocs.googlecode.com/git/git-add.html\n\nBut, look at\nhttps://www.kernel.org/pub/software/scm/git/docs/git-add.html\n\nThis page seems to need an update too, and I wonder why:\na) The makefile did'nt re-generate html even if it should have\nb) That page is not owned or updated by the git.git maintainer\nc) Any other reason?\n\n\nDoes anybody know how to trigger an update at kernel.org?\n\n/Torsten\n"},{"id":"233989","messageId":"xmqqppn8ggzi.fsf@gitster.dls.corp.google.com","threadId":"35544","inReplyTo":"52EA3A07.2090203@web.de","subject":"Re: [PATCH] add: don't complain when adding empty project root","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-01-31T18:10:09Z","receivedAt":"2014-01-31T18:10:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Torsten Bögershausen <tboegi@web.de> writes:\n\n> But, look at\n> https://www.kernel.org/pub/software/scm/git/docs/git-add.html\n>\n> This page seems to need an update too, and I wonder why:\n> a) The makefile did'nt re-generate html even if it should have\n> b) That page is not owned or updated by the git.git maintainer\n> c) Any other reason?\n\nSorry, but if I understand correctly, k.org these days requires each\nfile to be GPG signed and uploaded individually (i.e. there is no\nway as far as I can tell to say \"here is a tarball, and I've even\nsigned it with my key to convince you that it is from me. Please\naccept it and then unpack the contents there\").  There is no way I'd\ndo that every time I update git-htmldocs repository for 500+ files.\n"}]}