]> git.ipfire.org Git - thirdparty/git.git/commit
parse-options: exit 0 on -h
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 8 Jul 2026 00:15:57 +0000 (00:15 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Jul 2026 00:48:57 +0000 (17:48 -0700)
commitcdaf12f762855b293829ccf540698f86ccb9655e
treebb7d423fe28840109436b6560a56c4713c519af0
parent06f9b9501afcdf2f64c1d9a2fce964da824fe054
parse-options: exit 0 on -h

The standard philosophy for Unix software when a help option (such as
--help) is specified is that the software should exit 0, printing the
help output to standard output, since the standard output is for
user-requested output and the program performed the requested task
successfully.  If the user specifies an incorrect option, then the help
output should be printed to standard error (since the user has made a
mistake) and it should exit unsuccessfully.

Most of our commands currently exit 129 on receiving the -h option to
print the short help, which does not line up with the standard
philosophy above.  Let's change that to exit 0 instead.

This requires changes to a variety of tests which previously wanted the
129 exit code, so update them.  Note that because git diff does its own
option parsing, it still exits with 129, so update some of the tests to
expect either exit status.

Some commands also now pass with -h but not --help-all, so handle those
cases differently for those commands.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
37 files changed:
builtin/blame.c
builtin/shortlog.c
builtin/update-index.c
contrib/subtree/t/t7900-subtree.sh
parse-options.c
t/for-each-ref-tests.sh
t/t0012-help.sh
t/t0040-parse-options.sh
t/t0450-txt-doc-vs-help.sh
t/t0610-reftable-basics.sh
t/t1403-show-ref.sh
t/t1410-reflog.sh
t/t1418-reflog-exists.sh
t/t1502-rev-parse-parseopt.sh
t/t1517-outside-repo.sh
t/t1800-hook.sh
t/t1900-repo-info.sh
t/t1901-repo-structure.sh
t/t2006-checkout-index-basic.sh
t/t2107-update-index-basic.sh
t/t3004-ls-files-basic.sh
t/t3200-branch.sh
t/t3903-stash.sh
t/t4200-rerere.sh
t/t5200-update-server-info.sh
t/t5304-prune.sh
t/t5400-send-pack.sh
t/t5512-ls-remote.sh
t/t6300-for-each-ref.sh
t/t6500-gc.sh
t/t7030-verify-tag.sh
t/t7508-status.sh
t/t7510-signed-commit.sh
t/t7600-merge.sh
t/t7800-difftool.sh
t/t7900-maintenance.sh
usage.c