Skip to content

Commit 8743326

Browse files
peffgitster
authored andcommitted
parse-options: print "fatal:" before usage_msg_opt()
Programs may use usage_msg_opt() to print a brief message followed by the program usage, and then exit. The message isn't prefixed at all, though, so it doesn't match our usual error output and is easy to overlook: $ git clone 1 2 3 Too many arguments. usage: git clone [<options>] [--] <repo> [<dir>] -v, --verbose be more verbose -q, --quiet be more quiet --progress force progress reporting -n, --no-checkout don't create a checkout --bare create a bare repository [...and so on for another 31 lines...] It looks especially bad when the message starts with an option, like: $ git replace -e -e needs exactly one argument usage: git replace [-f] <object> <replacement> or: git replace [-f] --edit <object> [...etc...] Let's put our usual "fatal:" prefix in front of it. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0202c41 commit 8743326

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

parse-options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ void NORETURN usage_msg_opt(const char *msg,
661661
const char * const *usagestr,
662662
const struct option *options)
663663
{
664-
fprintf(stderr, "%s\n\n", msg);
664+
fprintf(stderr, "fatal: %s\n\n", msg);
665665
usage_with_options(usagestr, options);
666666
}
667667

0 commit comments

Comments
 (0)