From: Jeff King <peff@peff.net>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] rev-parse: have --parseopt callers exit 0 on --help
Date: Tue, 17 Mar 2026 11:07:59 -0400 [thread overview]
Message-ID: <20260317150759.GA9975@coredump.intra.peff.net> (raw)
In-Reply-To: <20260317145543.GA1828@coredump.intra.peff.net>
On Tue, Mar 17, 2026 at 10:55:43AM -0400, Jeff King wrote:
> I agree with the general idea that "-h" usually should exit 0. But this
> is not just a bug fix for --parseopt, but a change in overall intent. It
> might be worth digging in the commit history or list archive to see if
> there's any discussion on why we are using 129 in the first place.
I dug around a little but couldn't find anything conclusive. The first
"129" goes back to 2007:
https://lore.kernel.org/git/20071013221450.GC2875@steel.home/
But there (and most spots where it is added) it is being used to show
options when we have an unknown option. So I _think_ what mostly
happened is that we show options in two different scenarios: on an
error, and when somebody asks for "-h". And we never differentiated the
two, and the latter just inherited the exit code for the former.
For example, when you look at ff43ec3e2d (parse-opt: create
parse_options_step., 2008-06-23), it introduces:
+ switch (parse_options_step(&ctx, options, usagestr)) {
+ case PARSE_OPT_HELP:
+ exit(129);
and only later did we add PARSE_OPT_ERROR to that switch statement. And
back then, PARSE_OPT_HELP came only from running usage_with_options().
But I couldn't find any discussion or intentional use of 129 for "-h"
output. I do suspect that there may still be some untangling to do. In
the earlier (again, untested) patch I showed, I put an exit(0) for that
PARSE_OPT_HELP case. But it may be that there's more surgery needed to
differentiate "we showed help because of -h" versus "we showed help
because you gave a bogus option".
-Peff
next prev parent reply other threads:[~2026-03-17 15:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-15 0:52 Unexpected exit code for --help with rev-parse --parseopt brian m. carlson
2026-03-15 3:14 ` Jeff King
2026-03-15 16:59 ` brian m. carlson
2026-03-15 18:16 ` Jeff King
2026-03-16 22:07 ` [PATCH] rev-parse: have --parseopt callers exit 0 on --help brian m. carlson
2026-03-17 0:47 ` Junio C Hamano
2026-03-17 11:59 ` brian m. carlson
2026-03-17 14:55 ` Jeff King
2026-03-17 15:07 ` Jeff King [this message]
2026-03-17 17:06 ` Junio C Hamano
2026-03-17 18:44 ` Jeff King
2026-03-18 0:24 ` brian m. carlson
2026-03-18 1:22 ` Jeff King
2026-03-18 2:45 ` 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=20260317150759.GA9975@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sandals@crustytoothpaste.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.