{"thread":{"id":"50788","subject":"[PATCH] commit: improve error message in \"-a <paths>\" case","startedAt":"2019-03-20T10:29:15Z","lastAt":"2019-03-21T09:42:38Z","messageCount":3,"participants":["Nguyễn Thái Ngọc Duy","Junio C Hamano","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"371975","messageId":"20190320102906.12917-1-pclouds@gmail.com","threadId":"50788","inReplyTo":null,"subject":"[PATCH] commit: improve error message in \"-a <paths>\" case","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-20T10:29:06Z","receivedAt":"2019-03-20T10:29:15Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"I did something stupid today and got\n\n    $ git commit -a --fixup= @^\n    fatal: Paths with -a does not make sense.\n\nwhich didn't make any sense (at least for the first few seconds).\n\nInclude the first path(spec) in the error message to help spot the\nproblem quicker. Now it shows\n\n    fatal: paths '@^ ...' with -a does not make sense\n\nwhich should ring some bell because @^ should clearly not be considered\na path.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/commit.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex f17537474a..7f9aa032b6 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1194,7 +1194,8 @@ static int parse_and_validate_options(int argc, const char *argv[],\n \thandle_untracked_files_arg(s);\n \n \tif (all && argc > 0)\n-\t\tdie(_(\"Paths with -a does not make sense.\"));\n+\t\tdie(_(\"paths '%s ...' with -a does not make sense\"),\n+\t\t    argv[0]);\n \n \tif (status_format != STATUS_FORMAT_NONE)\n \t\tdry_run = 1;\n-- \n2.21.0.548.gd3c7d92dc2\n\n"},{"id":"372056","messageId":"xmqqh8bwsrnj.fsf@gitster-ct.c.googlers.com","threadId":"50788","inReplyTo":"20190320102906.12917-1-pclouds@gmail.com","subject":"Re: [PATCH] commit: improve error message in \"-a <paths>\" case","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-03-21T05:49:52Z","receivedAt":"2019-03-21T05:49:57Z","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> I did something stupid today and got\n>\n>     $ git commit -a --fixup= @^\n>     fatal: Paths with -a does not make sense.\n>\n> which didn't make any sense (at least for the first few seconds).\n>\n> Include the first path(spec) in the error message to help spot the\n> problem quicker. Now it shows\n>\n>     fatal: paths '@^ ...' with -a does not make sense\n>\n> which should ring some bell because @^ should clearly not be considered\n> a path.\n\nMakes sort of sense.  Would it break to blindly use argv[0] if the\nuser had an explicit double-dash \"--\" disambiguator?\n\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  builtin/commit.c | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index f17537474a..7f9aa032b6 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -1194,7 +1194,8 @@ static int parse_and_validate_options(int argc, const char *argv[],\n>  \thandle_untracked_files_arg(s);\n>  \n>  \tif (all && argc > 0)\n> -\t\tdie(_(\"Paths with -a does not make sense.\"));\n> +\t\tdie(_(\"paths '%s ...' with -a does not make sense\"),\n> +\t\t    argv[0]);\n>  \n>  \tif (status_format != STATUS_FORMAT_NONE)\n>  \t\tdry_run = 1;\n"},{"id":"372082","messageId":"CACsJy8CbpQs6_vH9P2T_BY8F3RHv0Y1M8NL-q0HNj7xOz4Wcjg@mail.gmail.com","threadId":"50788","inReplyTo":"xmqqh8bwsrnj.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] commit: improve error message in \"-a <paths>\" case","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-03-21T09:42:09Z","receivedAt":"2019-03-21T09:42:38Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Mar 21, 2019 at 12:49 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n> > I did something stupid today and got\n> >\n> >     $ git commit -a --fixup= @^\n> >     fatal: Paths with -a does not make sense.\n> >\n> > which didn't make any sense (at least for the first few seconds).\n> >\n> > Include the first path(spec) in the error message to help spot the\n> > problem quicker. Now it shows\n> >\n> >     fatal: paths '@^ ...' with -a does not make sense\n> >\n> > which should ring some bell because @^ should clearly not be considered\n> > a path.\n>\n> Makes sort of sense.  Would it break to blindly use argv[0] if the\n> user had an explicit double-dash \"--\" disambiguator?\n\nGood point. I didn't think of this.\n\n$ ./git commit -a --fixup= @^ -- foo\nfatal: paths '@^ ...' with -a does not make sense\n\nso on the bright side the error message still reports the right thing.\n\nBut parseopt I think does something wrong because @^ should not be\nconsidered a path at all. There should be some other error message\nabout unrecognized option \"@^\". I checked argv, argv[0] is \"@^\",\nargv[1] is \"foo\" and \"--\" stripped.\n\nThis I think is a separate bug. Will look into it when I have more\ntime (and tagging #leftovers in case people look for something fun and\nsmall to do)\n-- \nDuy\n"}]}