git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] parse-options: print "fatal:" before usage_msg_opt()
@ 2016-12-14 15:10 Jeff King
  2016-12-14 17:57 ` Junio C Hamano
  2016-12-19 12:07 ` Duy Nguyen
  0 siblings, 2 replies; 8+ messages in thread
From: Jeff King @ 2016-12-14 15:10 UTC (permalink / raw)
  To: git

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 <peff@peff.net>
---
Some of the message in git-clone could stand to be rewritten to match
our usual style, too (no capitals, no trailing period), but that's
obviously out of scope for this patch. I don't think this change makes
them look any worse.

 parse-options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parse-options.c b/parse-options.c
index 312a85dbd..4fbe924a5 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -661,7 +661,7 @@ void NORETURN usage_msg_opt(const char *msg,
 		   const char * const *usagestr,
 		   const struct option *options)
 {
-	fprintf(stderr, "%s\n\n", msg);
+	fprintf(stderr, "fatal: %s\n\n", msg);
 	usage_with_options(usagestr, options);
 }
 
-- 
2.11.0.341.g202cd3142

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-12-19 15:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-14 15:10 [PATCH] parse-options: print "fatal:" before usage_msg_opt() Jeff King
2016-12-14 17:57 ` Junio C Hamano
2016-12-19 12:07 ` Duy Nguyen
2016-12-19 13:41   ` Jeff King
2016-12-19 13:53     ` Duy Nguyen
2016-12-19 14:05       ` Jeff King
2016-12-19 14:30         ` Duy Nguyen
2016-12-19 14:32           ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).