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>
This commit is contained in:
Junio C Hamano
2025-01-16 13:35:53 -08:00
parent a36a822d7d
commit f66d1423f5
19 changed files with 37 additions and 32 deletions

View File

@ -619,6 +619,8 @@ int cmd_unpack_objects(int argc,
quiet = !isatty(2);
show_usage_if_asked(argc, argv, unpack_usage);
for (i = 1 ; i < argc; i++) {
const char *arg = argv[i];