{"thread":{"id":"44573","subject":"\"git add -p .\" raises an unexpected \"warning: empty strings as pathspecs will be made invalid in upcoming releases. please use . instead if you meant to match all paths\"","startedAt":"2016-11-30T20:32:54Z","lastAt":"2016-12-06T21:21:19Z","messageCount":6,"participants":["Peter Urda","Kevin Daudt","Junio C Hamano","Brandon Williams"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"306600","messageId":"CAEnOLdvG=SoKFxeJ_pLmamGj_8osC+28TSg+pbFLLTr+ZLcpQA@mail.gmail.com","threadId":"44573","inReplyTo":null,"subject":"\"git add -p .\" raises an unexpected \"warning: empty strings as pathspecs will be made invalid in upcoming releases. please use . instead if you meant to match all paths\"","fromName":"Peter Urda","fromEmail":"peter.urda@gmail.com","sentAt":"2016-11-30T20:31:49Z","receivedAt":"2016-11-30T20:32:54Z","isPatch":false,"sender":{"key":"peter.urda@gmail.com","avatar":null},"body":"After upgrading to version 2.11.0 I am getting a warning about empty\nstrings as pathspecs while using 'patch'\n\n- Ran 'git add -p .' from the root of my git repository.\n\n- I was able to normally stage my changes, but was presented with a\n\"warning: empty strings as pathspecs will be made invalid in upcoming\nreleases. please use . instead if you meant to match all paths\"\nmessage.\n\n- I expected no warning message since I included a \".\" with my original command.\n\nI believe that I should not be seeing this warning message as I\nincluded the requested \".\" pathspec.\n\n~ Peter Urda\n\nhttp://urda.cc\n"},{"id":"306615","messageId":"20161130211100.GA18680@ikke.info","threadId":"44573","inReplyTo":"CAEnOLdvG=SoKFxeJ_pLmamGj_8osC+28TSg+pbFLLTr+ZLcpQA@mail.gmail.com","subject":"Re: \"git add -p .\" raises an unexpected \"warning: empty strings as pathspecs will be made invalid in upcoming releases. please use . instead if you meant to match all paths\"","fromName":"Kevin Daudt","fromEmail":"me@ikke.info","sentAt":"2016-11-30T21:11:00Z","receivedAt":"2016-11-30T21:29:23Z","isPatch":false,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Wed, Nov 30, 2016 at 12:31:49PM -0800, Peter Urda wrote:\n> After upgrading to version 2.11.0 I am getting a warning about empty\n> strings as pathspecs while using 'patch'\n> \n> - Ran 'git add -p .' from the root of my git repository.\n> \n> - I was able to normally stage my changes, but was presented with a\n> \"warning: empty strings as pathspecs will be made invalid in upcoming\n> releases. please use . instead if you meant to match all paths\"\n> message.\n> \n> - I expected no warning message since I included a \".\" with my original command.\n> \n> I believe that I should not be seeing this warning message as I\n> included the requested \".\" pathspec.\n> \n> ~ Peter Urda\n> \n> http://urda.cc\n\nI can reproduce this. Note that it only happens when you specify '-p'.\nWithout the --patch option, the warning does not appear.\n"},{"id":"306625","messageId":"xmqq7f7kd3pj.fsf@gitster.mtv.corp.google.com","threadId":"44573","inReplyTo":"20161130211100.GA18680@ikke.info","subject":"Re: \"git add -p .\" raises an unexpected \"warning: empty strings as pathspecs will be made invalid in upcoming releases. please use . instead if you meant to match all paths\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-11-30T22:04:40Z","receivedAt":"2016-11-30T22:04:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Daudt <me@ikke.info> writes:\n\n> On Wed, Nov 30, 2016 at 12:31:49PM -0800, Peter Urda wrote:\n>> After upgrading to version 2.11.0 I am getting a warning about empty\n>> strings as pathspecs while using 'patch'\n>> \n>> - Ran 'git add -p .' from the root of my git repository.\n>> \n>> - I was able to normally stage my changes, but was presented with a\n>> \"warning: empty strings as pathspecs will be made invalid in upcoming\n>> releases. please use . instead if you meant to match all paths\"\n>> message.\n>> \n>> - I expected no warning message since I included a \".\" with my original command.\n>> \n>> I believe that I should not be seeing this warning message as I\n>> included the requested \".\" pathspec.\n\nYes, this seems to be caused by pathspec.c::prefix_pathspec()\noverwriting the original pathspec \".\" into \"\".  The callchain\nlooks like this:\n\n    builtin/add.c::interactive_add()\n     -> parse_pathspec()\n        passes argv[] that has \".\" to the caller,\n        receives pathspec whose pathspec->items[].original\n\tis supposed to point at the unmolested original,\n        but prefix_pathspec() munges \".\" into \"\"\n     -> run_add_interactive()\n        which runs \"git add--interactive\" with\n\tpathspec->items[].original as pathspecs\n\n\nPerhaps this would work it around, but there should be a better way\nto fix it (like, making sure that what we call \"original\" indeed\nstays \"original\").\n\n builtin/add.c | 13 +++++++++++--\n 1 file changed, 11 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex e8fb80b36e..137097192d 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -167,9 +167,18 @@ int run_add_interactive(const char *revision, const char *patch_mode,\n \tif (revision)\n \t\targv_array_push(&argv, revision);\n \targv_array_push(&argv, \"--\");\n-\tfor (i = 0; i < pathspec->nr; i++)\n+\tfor (i = 0; i < pathspec->nr; i++) {\n \t\t/* pass original pathspec, to be re-parsed */\n+\t\tif (!*pathspec->items[i].original) {\n+\t\t\t/*\n+\t\t\t * work around a misfeature in parse_pathspecs()\n+\t\t\t * that munges \".\" into \"\".\n+\t\t\t */\n+\t\t\targv_array_push(&argv, \".\");\n+\t\t\tcontinue;\n+\t\t}\n \t\targv_array_push(&argv, pathspec->items[i].original);\n+\t}\n \n \tstatus = run_command_v_opt(argv.argv, RUN_GIT_CMD);\n \targv_array_clear(&argv);\n@@ -180,7 +189,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)\n {\n \tstruct pathspec pathspec;\n \n-\tparse_pathspec(&pathspec, 0,\n+\tparse_pathspec(&pathspec, 0,\n \t\t       PATHSPEC_PREFER_FULL |\n \t\t       PATHSPEC_SYMLINK_LEADING_PATH |\n \t\t       PATHSPEC_PREFIX_ORIGIN,\n"},{"id":"306631","messageId":"xmqqtwaobni5.fsf@gitster.mtv.corp.google.com","threadId":"44573","inReplyTo":"xmqq7f7kd3pj.fsf@gitster.mtv.corp.google.com","subject":"Re: \"git add -p .\" raises an unexpected \"warning: empty strings as pathspecs will be made invalid in upcoming releases. please use . instead if you meant to match all paths\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-11-30T22:40:02Z","receivedAt":"2016-11-30T22:40:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> forgot to Cc: the author of the\nmost relevant change to the issue, d426430e6e (\"pathspec: warn on\nempty strings as pathspec\", 2016-06-22).\n\n> Kevin Daudt <me@ikke.info> writes:\n>\n>> On Wed, Nov 30, 2016 at 12:31:49PM -0800, Peter Urda wrote:\n>>> After upgrading to version 2.11.0 I am getting a warning about empty\n>>> strings as pathspecs while using 'patch'\n>>> \n>>> - Ran 'git add -p .' from the root of my git repository.\n>>> \n>>> - I was able to normally stage my changes, but was presented with a\n>>> \"warning: empty strings as pathspecs will be made invalid in upcoming\n>>> releases. please use . instead if you meant to match all paths\"\n>>> message.\n>>> \n>>> - I expected no warning message since I included a \".\" with my original command.\n>>> \n>>> I believe that I should not be seeing this warning message as I\n>>> included the requested \".\" pathspec.\n>\n> Yes, this seems to be caused by pathspec.c::prefix_pathspec()\n> overwriting the original pathspec \".\" into \"\".  The callchain\n> looks like this:\n>\n>     builtin/add.c::interactive_add()\n>      -> parse_pathspec()\n>         passes argv[] that has \".\" to the caller,\n>         receives pathspec whose pathspec->items[].original\n> \tis supposed to point at the unmolested original,\n>         but prefix_pathspec() munges \".\" into \"\"\n>      -> run_add_interactive()\n>         which runs \"git add--interactive\" with\n> \tpathspec->items[].original as pathspecs\n>\n>\n> Perhaps this would work it around, but there should be a better way\n> to fix it (like, making sure that what we call \"original\" indeed\n> stays \"original\").\n>\n>  builtin/add.c | 13 +++++++++++--\n>  1 file changed, 11 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/add.c b/builtin/add.c\n> index e8fb80b36e..137097192d 100644\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -167,9 +167,18 @@ int run_add_interactive(const char *revision, const char *patch_mode,\n>  \tif (revision)\n>  \t\targv_array_push(&argv, revision);\n>  \targv_array_push(&argv, \"--\");\n> -\tfor (i = 0; i < pathspec->nr; i++)\n> +\tfor (i = 0; i < pathspec->nr; i++) {\n>  \t\t/* pass original pathspec, to be re-parsed */\n> +\t\tif (!*pathspec->items[i].original) {\n> +\t\t\t/*\n> +\t\t\t * work around a misfeature in parse_pathspecs()\n> +\t\t\t * that munges \".\" into \"\".\n> +\t\t\t */\n> +\t\t\targv_array_push(&argv, \".\");\n> +\t\t\tcontinue;\n> +\t\t}\n>  \t\targv_array_push(&argv, pathspec->items[i].original);\n> +\t}\n>  \n>  \tstatus = run_command_v_opt(argv.argv, RUN_GIT_CMD);\n>  \targv_array_clear(&argv);\n> @@ -180,7 +189,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)\n>  {\n>  \tstruct pathspec pathspec;\n>  \n> -\tparse_pathspec(&pathspec, 0,\n> +\tparse_pathspec(&pathspec, 0,\n>  \t\t       PATHSPEC_PREFER_FULL |\n>  \t\t       PATHSPEC_SYMLINK_LEADING_PATH |\n>  \t\t       PATHSPEC_PREFIX_ORIGIN,\n"},{"id":"307021","messageId":"20161206180400.GA103573@google.com","threadId":"44573","inReplyTo":"xmqqtwaobni5.fsf@gitster.mtv.corp.google.com","subject":"Re: \"git add -p .\" raises an unexpected \"warning: empty strings as pathspecs will be made invalid in upcoming releases. please use . instead if you meant to match all paths\"","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2016-12-06T18:04:00Z","receivedAt":"2016-12-06T18:04:09Z","isPatch":false,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 11/30, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> forgot to Cc: the author of the\n> most relevant change to the issue, d426430e6e (\"pathspec: warn on\n> empty strings as pathspec\", 2016-06-22).\n> \n> > Kevin Daudt <me@ikke.info> writes:\n> >\n> >> On Wed, Nov 30, 2016 at 12:31:49PM -0800, Peter Urda wrote:\n> >>> After upgrading to version 2.11.0 I am getting a warning about empty\n> >>> strings as pathspecs while using 'patch'\n> >>> \n> >>> - Ran 'git add -p .' from the root of my git repository.\n> >>> \n> >>> - I was able to normally stage my changes, but was presented with a\n> >>> \"warning: empty strings as pathspecs will be made invalid in upcoming\n> >>> releases. please use . instead if you meant to match all paths\"\n> >>> message.\n> >>> \n> >>> - I expected no warning message since I included a \".\" with my original command.\n> >>> \n> >>> I believe that I should not be seeing this warning message as I\n> >>> included the requested \".\" pathspec.\n> >\n> > Yes, this seems to be caused by pathspec.c::prefix_pathspec()\n> > overwriting the original pathspec \".\" into \"\".  The callchain\n> > looks like this:\n> >\n> >     builtin/add.c::interactive_add()\n> >      -> parse_pathspec()\n> >         passes argv[] that has \".\" to the caller,\n> >         receives pathspec whose pathspec->items[].original\n> > \tis supposed to point at the unmolested original,\n> >         but prefix_pathspec() munges \".\" into \"\"\n> >      -> run_add_interactive()\n> >         which runs \"git add--interactive\" with\n> > \tpathspec->items[].original as pathspecs\n> >\n> >\n> > Perhaps this would work it around, but there should be a better way\n> > to fix it (like, making sure that what we call \"original\" indeed\n> > stays \"original\").\n> >\n> >  builtin/add.c | 13 +++++++++++--\n> >  1 file changed, 11 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/builtin/add.c b/builtin/add.c\n> > index e8fb80b36e..137097192d 100644\n> > --- a/builtin/add.c\n> > +++ b/builtin/add.c\n> > @@ -167,9 +167,18 @@ int run_add_interactive(const char *revision, const char *patch_mode,\n> >  \tif (revision)\n> >  \t\targv_array_push(&argv, revision);\n> >  \targv_array_push(&argv, \"--\");\n> > -\tfor (i = 0; i < pathspec->nr; i++)\n> > +\tfor (i = 0; i < pathspec->nr; i++) {\n> >  \t\t/* pass original pathspec, to be re-parsed */\n> > +\t\tif (!*pathspec->items[i].original) {\n> > +\t\t\t/*\n> > +\t\t\t * work around a misfeature in parse_pathspecs()\n> > +\t\t\t * that munges \".\" into \"\".\n> > +\t\t\t */\n> > +\t\t\targv_array_push(&argv, \".\");\n> > +\t\t\tcontinue;\n> > +\t\t}\n> >  \t\targv_array_push(&argv, pathspec->items[i].original);\n> > +\t}\n> >  \n> >  \tstatus = run_command_v_opt(argv.argv, RUN_GIT_CMD);\n> >  \targv_array_clear(&argv);\n> > @@ -180,7 +189,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)\n> >  {\n> >  \tstruct pathspec pathspec;\n> >  \n> > -\tparse_pathspec(&pathspec, 0,\n> > +\tparse_pathspec(&pathspec, 0,\n> >  \t\t       PATHSPEC_PREFER_FULL |\n> >  \t\t       PATHSPEC_SYMLINK_LEADING_PATH |\n> >  \t\t       PATHSPEC_PREFIX_ORIGIN,\n\nI've been doing a bit of work trying to clean up the pathspec\ninitialization code and I believe this can be fixed without\nhaving to add in this work around.  The code which does the munging is\nalways trying to prefix the pathspec regardless if there is a prefix or\nnot.  If instead its changed to only try and prefix the original if\nthere is indeed a prefix, then it should fix the munging.\n\nI'll try to get the series I'm working on out in the next day.\n\n-- \nBrandon Williams\n"},{"id":"307050","messageId":"xmqqlgvszrco.fsf@gitster.mtv.corp.google.com","threadId":"44573","inReplyTo":"20161206180400.GA103573@google.com","subject":"Re: \"git add -p .\" raises an unexpected \"warning: empty strings as pathspecs will be made invalid in upcoming releases. please use . instead if you meant to match all paths\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-12-06T21:21:11Z","receivedAt":"2016-12-06T21:21:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Williams <bmwill@google.com> writes:\n\n> On 11/30, Junio C Hamano wrote:\n>> Junio C Hamano <gitster@pobox.com> forgot to Cc: the author of the\n>> most relevant change to the issue, d426430e6e (\"pathspec: warn on\n>> empty strings as pathspec\", 2016-06-22).\n>> ...\n>\n> I've been doing a bit of work trying to clean up the pathspec\n> initialization code and I believe this can be fixed without\n> having to add in this work around.  The code which does the munging is\n> always trying to prefix the pathspec regardless if there is a prefix or\n> not.  If instead its changed to only try and prefix the original if\n> there is indeed a prefix, then it should fix the munging.\n\nThanks; sounds like a plan.\n"}]}