diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-01-28 13:02:22 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-01-28 13:02:22 -0800 |
| commit | f0a371a39d8b9945b2e0a414a32aa861614e5352 (patch) | |
| tree | 5ee935ae11355384d47bc2da81d6a19bf2ae15cb /parse-options.c | |
| parent | The third batch (diff) | |
| parent | builtin: send usage() help text to standard output (diff) | |
| download | git-f0a371a39d8b9945b2e0a414a32aa861614e5352.tar.gz git-f0a371a39d8b9945b2e0a414a32aa861614e5352.zip | |
Merge branch 'jc/show-usage-help'
The help text from "git $cmd -h" appear on the standard output for
some $cmd and the standard error for others. The built-in commands
have been fixed to show them on the standard output consistently.
* jc/show-usage-help:
builtin: send usage() help text to standard output
oddballs: send usage() help text to standard output
builtins: send usage_with_options() help text to standard output
usage: add show_usage_if_asked()
parse-options: add show_usage_with_options_if_asked()
t0012: optionally check that "-h" output goes to stdout
Diffstat (limited to 'parse-options.c')
| -rw-r--r-- | parse-options.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c index 3ff6a5d1fa..35fbb3b0d6 100644 --- a/parse-options.c +++ b/parse-options.c @@ -1319,6 +1319,16 @@ void NORETURN usage_with_options(const char * const *usagestr, exit(129); } +void show_usage_with_options_if_asked(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(129); + } +} + void NORETURN usage_msg_opt(const char *msg, const char * const *usagestr, const struct option *options) |
