@matheusbsbs / matheus-bagliano / commits / b57c68a69e
Fork 0

parse-options: never suppress arghelp if LITERAL_ARGHELP is set

The PARSE_OPT_LITERAL_ARGHELP flag allows a program to override the standard "<argument> for mandatory, [argument] for optional" markup in its help message. Extend it to override the usual "no text for disallowed", too (for the PARSE_OPT_NOARG | PARSE_OPT_LITERAL_ARGHELP case, which was previously meaningless), to be more intuitive. The motivation is to allow update-index to correctly advertise --cacheinfo <mode> <object> <path> add the specified entry to the index while abusing PARSE_OPT_NOARG to disallow the "sticked form" --cacheinfo=<mode> <object> <path> Noticed-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Dec 1, 2010 at 17:31 UTC b57c68a69e028cc41eb01404dc4446a463c0e464
1 file changed +2 -1
parse-options.c
+2 -1
@@ -537,7 +537,8 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
537 if (opts->type == OPTION_NUMBER)
538 pos += fprintf(outfile, "-NUM");
539
540 - if (!(opts->flags & PARSE_OPT_NOARG))
540 + if ((opts->flags & PARSE_OPT_LITERAL_ARGHELP) ||
541 + !(opts->flags & PARSE_OPT_NOARG))
542 pos += usage_argh(opts, outfile);
543
544 if (pos <= USAGE_OPTS_WIDTH)