git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/5] show-ref: stop using PARSE_OPT_NO_INTERNAL_HELP

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 4, 2015, 18:40 UTC
Message-ID
<xmqqtwnyrraw.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<564B00BD.7010709@web.de>
René Scharfe <l.s.r@web.de> writes:
> The flag PARSE_OPT_NO_INTERNAL_HELP is set to allow overriding the
> option -h, except when it's the only one given.
> This is the default behavior now,...

OK, so in the old world order, "-h" used to trigger the internal help even before consulting parse_short_opt() to see if there is a handler supplied by the caller, and NO_INTERNAL_HELP was invented as a kludge to to disable this behaviour. The existing two users (dealt with 4/5 and 5/5) both used this mechanism to let their own handler kick in, but they had to make "-h" without anything else on the command line behave just like the internal one, while handling "-h" with something else on the command line do a custom thing.

In the new world order, internal "-h" handler is called only after seeing that parse_short_opt() decides there is no handler for "-h" as a fallback.

	Side note.  Not really.  Among the three uses of
	intenal_help in parse_options_step(), the first one ("lone
	-h asks for help") is used before we ask parse_short_opt().

I wonder if we can/want to further tweak this in a follow-up series. If that is done, I think NO_INTERNAL_HELP can go away, as its only effect would be to make us say "unknown option" when "-h" alone was given from the command line for an options[] array that does not have a handler for "-h".

Previous: René Scharfe
Message 7 of 7 in “parse-options: allow -h as a short option”
  1. 0/5 parse-options: allow -h as a short optionRené Scharfe, Nov 17, 2015
  2. 1/5 parse-options: deduplicate parse_options_usage() callsRené Scharfe, Nov 17, 2015
  3. 2/5 parse-options: inline parse_options_usage() at its only remaining callerRené Scharfe, Nov 17, 2015
  4. 3/5 parse-options: allow -h as a short optionRené Scharfe, Nov 17, 2015
  5. 4/5 grep: stop using PARSE_OPT_NO_INTERNAL_HELPRené Scharfe, Nov 17, 2015
  6. 5/5 show-ref: stop using PARSE_OPT_NO_INTERNAL_HELPRené Scharfe, Nov 17, 2015
  7. Junio C HamanoDec 4, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.