Jeff King <peff@xxxxxxxx> writes: > use that everywhere. Possibly it could even do the argc/argv check, too, > since every call site is going to be doing that itself. It would look something like this; I am not sure if I like the "this may show help and exit if the user requested, but otherwise it is a no-op" semantics, though. builtin/am.c | 3 +-- parse-options.c | 10 ++++++++++ parse-options.h | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git c/builtin/am.c w/builtin/am.c index 370f5593f2..c9571f605a 100644 --- c/builtin/am.c +++ w/builtin/am.c @@ -2417,8 +2417,7 @@ int cmd_am(int argc, const char **argv, const char *prefix) OPT_END() }; - if (argc == 2 && !strcmp(argv[1], "-h")) - usage_with_options(usage, options); + show_usage_help(argc, argv, usage, options); git_config(git_default_config, NULL); diff --git c/parse-options.c w/parse-options.c index 30b9e68f8a..9419b174de 100644 --- c/parse-options.c +++ w/parse-options.c @@ -1276,6 +1276,16 @@ void NORETURN usage_with_options(const char * const *usagestr, exit(129); } +void show_usage_help(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(0); + } +} + void NORETURN usage_msg_opt(const char *msg, const char * const *usagestr, const struct option *options) diff --git c/parse-options.h w/parse-options.h index ae15342390..75a7493350 100644 --- c/parse-options.h +++ w/parse-options.h @@ -388,6 +388,10 @@ int parse_options(int argc, const char **argv, const char *prefix, NORETURN void usage_with_options(const char * const *usagestr, const struct option *options); +void show_usage_help(int, const char **, + const char * const *usagestr, + const struct option *options); + NORETURN void usage_msg_opt(const char *msg, const char * const *usagestr, const struct option *options);