From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] parse-options: print "fatal:" before usage_msg_opt()
Date: Wed, 14 Dec 2016 09:57:55 -0800 [thread overview]
Message-ID: <xmqqr35axujg.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20161214151009.4wdzjb44f6aki5ug@sigill.intra.peff.net> (Jeff King's message of "Wed, 14 Dec 2016 10:10:10 -0500")
Jeff King <peff@peff.net> writes:
> 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.
I briefly wondered if any caller uses this in a non-fatal situation,
but usage_with_options() always dies, so this looks like the right
thing to do. Thanks.
>
> 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);
> }
next prev parent reply other threads:[~2016-12-14 17:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-14 15:10 [PATCH] parse-options: print "fatal:" before usage_msg_opt() Jeff King
2016-12-14 17:57 ` Junio C Hamano [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr35axujg.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).