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

Re: [PATCH 2/2] parseopt: check for duplicate long names and numerical options

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 27, 2026, 23:28 UTC
Message-ID
<xmqqpl5pojg6.fsf@gitster.g>
In-Reply-To
<20260227230822.GA2965111@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 20 quoted lines
> Doing this:
>
> diff --git a/parse-options.c b/parse-options.c
> index 51b72eee11..f056a4471e 100644
> --- a/parse-options.c
> +++ b/parse-options.c
> @@ -659,9 +659,8 @@ static void parse_options_check(const struct option *opts)
>  				optbug(opts, "short name already used");
>  		}
>  		if (opts->long_name) {
> -			if (strset_contains(&long_names, opts->long_name))
> +			if (!strset_add(&long_names, opts->long_name))
>  				optbug(opts, "long name already used");
> -			strset_add(&long_names, opts->long_name);
>  		}
>  		if (opts->type == OPTION_NUMBER) {
>  			if (saw_number_option)
>
> seems to shave off ~1% of my benchmark. Not that exciting, but hey, it's
> one line shorter to boot.

Yeah, it is the right thing not to hash the same thing twice which is totally unnecessary.

Previous: Jeff KingNext: René Scharfe
Message 5 of 12 in “[Bug] duplicated long-form options go unnoticed”
  1. Junio C HamanoFeb 27, 2026
  2. 2/2 parseopt: check for duplicate long names and numerical optionsRené Scharfe, Feb 27, 2026
  3. Jeff KingFeb 27, 2026
  4. Jeff KingFeb 27, 2026
  5. Junio C HamanoFeb 27, 2026
  6. René ScharfeFeb 28, 2026
  7. 2/2 parseopt: check for duplicate long names and numerical optionsRené Scharfe, Feb 28, 2026
  8. Jeff KingFeb 28, 2026
  9. René ScharfeFeb 28, 2026
  10. Jeff KingMar 2, 2026
  11. Junio C HamanoMar 1, 2026
  12. 1/2 pack-objects: remove duplicate --stdin-packs definitionRené Scharfe, Feb 27, 2026

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.