commit: improve error message in "-a <paths>" case
PATCH 1/1 commit: improve error message in "-a <paths>" case
I did something stupid today and got
$ git commit -a --fixup= @^
fatal: Paths with -a does not make sense.which didn't make any sense (at least for the first few seconds).
Include the first path(spec) in the error message to help spot the problem quicker. Now it shows
fatal: paths '@^ ...' with -a does not make sense
which should ring some bell because @^ should clearly not be considered a path.
--- builtin/commit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
builtin/commit.c +2 -1
@@ -1194,7 +1194,8 @@ static int parse_and_validate_options(int argc, const char *argv[],handle_untracked_files_arg (s);if (all && argc >0 ) -die (_ ("Paths with -a does not make sense." )); +die (_ ("paths '%s ...' with -a does not make sense" ), + argv[0 ]);if (status_format !=STATUS_FORMAT_NONE ) dry_run =1 ;
Signature · 1 line
2.21.0.548.gd3c7d92dc2
Quoted 7 lines · Nguyễn Thái Ngọc Duy
I did something stupid today and got
$ git commit -a --fixup= @^ fatal: Paths with -a does not make sense.which didn't make any sense (at least for the first few seconds).
Quoted 7 lines
Include the first path(spec) in the error message to help spot the problem quicker. Now it shows
fatal: paths '@^ ...' with -a does not make sense
which should ring some bell because @^ should clearly not be considered a path.
Makes sort of sense. Would it break to blindly use argv[0] if the user had an explicit double-dash "--" disambiguator?
Quoted 20 lines
Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>--- builtin/commit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)builtin/commit.c +2
-1@@ -1194,7 +1194,8 @@ static int parse_and_validate_options(int argc, const char *argv[],handle_untracked_files_arg (s);if (all && argc >0 ) -die (_ ("Paths with -a does not make sense." )); +die (_ ("paths '%s ...' with -a does not make sense" ), + argv[0 ]);if (status_format !=STATUS_FORMAT_NONE ) dry_run =1 ;
Quoted 13 lines · Junio C Hamano
Quoted 10 lines · Nguyễn Thái Ngọc Duy
I did something stupid today and got
$ git commit -a --fixup= @^ fatal: Paths with -a does not make sense.which didn't make any sense (at least for the first few seconds).
Include the first path(spec) in the error message to help spot the problem quicker. Now it shows
Quoted 7 lines
Quoted 4 lines
fatal: paths '@^ ...' with -a does not make sense
which should ring some bell because @^ should clearly not be considered a path.
Makes sort of sense. Would it break to blindly use argv[0] if the user had an explicit double-dash "--" disambiguator?
Good point. I didn't think of this.
$ ./git commit -a --fixup= @^ -- foo fatal: paths '@^ ...' with -a does not make sense
so on the bright side the error message still reports the right thing.
But parseopt I think does something wrong because @^ should not be considered a path at all. There should be some other error message about unrecognized option "@^". I checked argv, argv[0] is "@^", argv[1] is "foo" and "--" stripped.
This I think is a separate bug. Will look into it when I have more time (and tagging #leftovers in case people look for something fun and small to do)
Signature · 1 line
Duy