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

[Bug] duplicated long-form options go unnoticed

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 27, 2026, 00:13 UTC
Message-ID
<xmqq5x7jujqb.fsf@gitster.g>

If you make this stupid change to builtin/cat-file.c, rebuild your git and run "git cat-file --batch-check", without anybody helping you notice that your change to add a duplicated long command to the options table is a nonsense. There should be some way to help the developer.

The most expensive would be a run-time check in parse_options_check(), which is not very advisable, but it may be OK to have one hidden behind a conditional debugging option (like exporting GIT_PARSEOPT_PARFNOID variable).

 builtin/cat-file.c | 1 +
 1 file changed, 1 insertion(+)
diff --git i/builtin/cat-file.c w/builtin/cat-file.c
index b6f12f41d6..eaa53b2b29 100644
--- i/builtin/cat-file.c
+++ w/builtin/cat-file.c
@@ -1091,6 +1091,7 @@ int cmd_cat_file(int argc,
 			N_("like --batch, but don't emit <contents>"),
 			PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
 			batch_option_callback),
+		OPT_BOOL(0, "batch-check", &batch, N_("batch")),
 		OPT_BOOL_F('z', NULL, &input_nul_terminated, N_("stdin is NUL-terminated"),
 			PARSE_OPT_HIDDEN),
 		OPT_BOOL('Z', NULL, &nul_terminated, N_("stdin and stdout is NUL-terminated")),
Next: René Scharfe
Message 1 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.