]> git.ipfire.org Git - thirdparty/git.git/commit
builtin: send usage() help text to standard output
authorJunio C Hamano <gitster@pobox.com>
Thu, 16 Jan 2025 21:35:53 +0000 (13:35 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Jan 2025 21:30:03 +0000 (13:30 -0800)
commitf66d1423f528403a33e8984f765801deb1b9cb97
tree9974ddbaecf7636163a66b79f379a68db16858d9
parenta36a822d7d42f36baf0b3d7a0af5691ce692ce20
builtin: send usage() help text to standard output

Using the show_usage_and_exit_if_asked() helper we introduced
earlier, fix callers of usage() that want to show the help text when
explicitly asked by the end-user.  The help text now goes to the
standard output stream for them.

These are the bog standard "if we got only '-h', then that is a
request for help" callers.  Their

if (argc == 2 && !strcmp(argv[1], "-h"))
usage(message);

are simply replaced with

show_usage_and_exit_if_asked(argc, argv, message);

With this, the built-ins tested by t0012 all send their help text to
their standard output stream, so the check in t0012 that was half
tightened earlier is now fully tightened to insist on standard error
stream being empty.

Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
19 files changed:
builtin/check-ref-format.c
builtin/diff-files.c
builtin/diff-index.c
builtin/diff-tree.c
builtin/fast-import.c
builtin/get-tar-commit-id.c
builtin/index-pack.c
builtin/mailsplit.c
builtin/merge-index.c
builtin/merge-ours.c
builtin/merge-recursive.c
builtin/pack-redundant.c
builtin/remote-ext.c
builtin/remote-fd.c
builtin/rev-list.c
builtin/rev-parse.c
builtin/unpack-objects.c
builtin/upload-archive.c
t/t0012-help.sh