All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>,
	"Matěj Cepl" <mcepl@cepl.eu>,
	"Jonas Konrad" <jonas.konrad@uni-muenster.de>,
	git@vger.kernel.org
Subject: Re: Git branch outputs usage message on stderr
Date: Wed, 15 Jan 2025 13:16:50 -0800	[thread overview]
Message-ID: <xmqqa5brydz1.fsf@gitster.g> (raw)
In-Reply-To: <20250115182419.GA86610@coredump.intra.peff.net> (Jeff King's message of "Wed, 15 Jan 2025 13:24:19 -0500")

Jeff King <peff@peff.net> writes:

> Yeah, I agree it is funny to have a "maybe noop, maybe exit" function.
> Perhaps a different name would help? I'd expect show_usage_help() to
> always do what the name says. Maybe check_help_option() or something?

maybe_show_usage_help()?

>> +void show_usage_help(int ac, const char **av,
>> +		     const char * const *usagestr,
>> +		     const struct option *opts)
>> +{
>> +	if (ac == 2 && !strcmp(av[1], "-h")) {
>> +		usage_with_options_internal(NULL, usagestr, opts, 0, 0);
>> +		exit(0);
>> +	}
>> +}
>
> I think parse-options will exit(129) in this case, and that's what t0012
> insists upon.

Yeah, but the test can be adjusted to updated reality if needed.  

In this case, the command is doing what the end-user asked it to do,
and if we were writing the system from scratch, 0 would certainly be
the right exit status in this case.  If hit usage_with_options()
because the command line option supplied by the user was nonsense,
we should exit with non-zero, but I am not sure if exit(129) is a
good idea here.

  reply	other threads:[~2025-01-15 21:16 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-15 11:21 Git branch outputs usage message on stderr Jonas Konrad
2025-01-15 11:36 ` Matěj Cepl
2025-01-15 14:47   ` Jonas Konrad
2025-01-15 15:28   ` Junio C Hamano
2025-01-15 16:55     ` Kristoffer Haugsbakk
2025-01-15 17:14       ` Jeff King
2025-01-15 17:49         ` Junio C Hamano
2025-01-15 17:56         ` Junio C Hamano
2025-01-15 18:24           ` Jeff King
2025-01-15 21:16             ` Junio C Hamano [this message]
2025-01-15 21:29               ` Jeff King
2025-01-15 21:56                 ` Junio C Hamano
2025-01-15 22:27                   ` Jeff King
2025-01-15 23:32                     ` Junio C Hamano
2025-01-16  1:21                       ` Junio C Hamano
2025-01-16 10:24                       ` Jeff King
2025-01-15 22:11                 ` Junio C Hamano
2025-01-15 22:28                   ` Jeff King
2025-01-15 23:35                     ` Junio C Hamano
2025-01-15 18:29           ` Junio C Hamano
2025-01-15 18:33             ` Kristoffer Haugsbakk
2025-01-15 21:13               ` Junio C Hamano
2025-01-15 17:14       ` Jonas Konrad
2025-01-15 17:53         ` Kristoffer Haugsbakk
2025-01-15 17:19       ` Junio C Hamano
2025-01-15 17:39         ` Kristoffer Haugsbakk
2025-01-15 17:47           ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa5brydz1.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jonas.konrad@uni-muenster.de \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=mcepl@cepl.eu \
    --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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.