Skip to content

Commit

Permalink
parse-options: never suppress arghelp if LITERAL_ARGHELP is set
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Dec 7, 2010
1 parent c1f4ec9 commit b57c68a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b57c68a

Please sign in to comment.