From b57c68a69e028cc41eb01404dc4446a463c0e464 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 1 Dec 2010 17:31:36 -0600 Subject: [PATCH] parse-options: never suppress arghelp if LITERAL_ARGHELP is set The PARSE_OPT_LITERAL_ARGHELP flag allows a program to override the standard " 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 add the specified entry to the index while abusing PARSE_OPT_NOARG to disallow the "sticked form" --cacheinfo= Noticed-by: Stephen Boyd Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- parse-options.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parse-options.c b/parse-options.c index 578035671a..632c1346c6 100644 --- a/parse-options.c +++ b/parse-options.c @@ -537,7 +537,8 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx, if (opts->type == OPTION_NUMBER) pos += fprintf(outfile, "-NUM"); - if (!(opts->flags & PARSE_OPT_NOARG)) + if ((opts->flags & PARSE_OPT_LITERAL_ARGHELP) || + !(opts->flags & PARSE_OPT_NOARG)) pos += usage_argh(opts, outfile); if (pos <= USAGE_OPTS_WIDTH) -- 2.11.4.GIT