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

[Outreachy PATCH v4 3/3] t0012: catch builtins that keep NO_PARSEOPT after conversion

From
TJTanga Joris <tangajoris@gmail.com>
Date
Nov 5, 2026, 00:39 UTC
Message-ID
<20261105003914.708836-3-tangajoris@gmail.com>
In-Reply-To
<20261105003914.708836-1-tangajoris@gmail.com>

When a builtin is converted to parse-options, the NO_PARSEOPT flag in git.c has to be removed by hand. No test checks this. The previous commit removes the flag from four builtins where it was left behind.

Add a test that runs "git <cmd> --git-completion-helper" for every builtin left out of "git --list-cmds=parseopt". The test fails if the command prints an option starting with "--". Without the previous commit, it fails for diff-pairs, fast-import and patch-id.

The test skips diff, diff-files, diff-index, diff-tree and rev-list, because they print the diff options. It also skips rev-parse, because it prints the argument back. It does not catch var, because var only has short options (like -l) and the helper only lists long options.

Suggested-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Tanga Joris <tangajoris@gmail.com>
---
Kaartic, I put your test in a separate patch for now, so it is easy to
find. I'm happy to squash it into 2/3 if you prefer it there.
 t/t0012-help.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff --git a/t/t0012-help.sh b/t/t0012-help.sh
index b0a3fdbbbc..41197c67e2 100755
--- a/t/t0012-help.sh
+++ b/t/t0012-help.sh
@@ -267,4 +267,29 @@ do
 	'
 done <builtins
 
+test_expect_success 'generate list of builtins without parse-options' '
+	git --list-cmds=parseopt >parseopt &&
+	tr " " "\n" <parseopt | sort >sorted-parseopt &&
+	sort builtins >sorted-builtins &&
+	comm -23 sorted-builtins sorted-parseopt >no-parseopt
+'
+
+while read builtin
+do
+	case "$builtin" in
+	# these answer with the diff options
+	diff|diff-files|diff-index|diff-tree|rev-list)
+		continue ;;
+	# rev-parse prints unknown arguments back
+	rev-parse)
+		continue ;;
+	esac
+
+	test_expect_success "$builtin does not answer --git-completion-helper" '
+		test_might_fail git $builtin --git-completion-helper \
+			</dev/null >output 2>/dev/null &&
+		test_grep ! "^--" output
+	'
+done <no-parseopt
+
 test_done
-- 
2.43.0
Previous: Tanga Joris
Message 18 of 18 in “git.c: drop NO_PARSEOPT from builtins that use parse-options”
  1. git.c: drop NO_PARSEOPT from builtins that use parse-optionsTanga Joris, Oct 24, 2026
  2. René ScharfeOct 25, 2026
  3. Tanga JorisOct 26, 2026
  4. Junio C HamanoOct 26, 2026
  5. 1/2 fast-import: handle --git-completion-helper before reading inputTanga Joris, Oct 29, 2026
  6. 2/2 git.c: drop NO_PARSEOPT from builtins that use parse-optionsTanga Joris, Oct 29, 2026
  7. Junio C HamanoOct 29, 2026
  8. 1/2 parse-options: answer --git-completion-helper before command runsTanga Joris, Oct 29, 2026
  9. 2/2 git.c: drop NO_PARSEOPT from builtins that use parse-optionsTanga Joris, Oct 29, 2026
  10. Kaartic SivaraamOct 30, 2026
  11. Tanga JorisNov 2, 2026
  12. Kaartic SivaraamOct 30, 2026
  13. Tanga JorisOct 31, 2026
  14. Cynthia UcheNov 3, 2026
  15. Tanga JorisNov 4, 2026
  16. 1/3 parse-options: answer --git-completion-helper before command runsTanga Joris, Nov 5, 2026
  17. 2/3 git.c: drop NO_PARSEOPT from builtins that use parse-optionsTanga Joris, Nov 5, 2026
  18. 3/3 t0012: catch builtins that keep NO_PARSEOPT after conversionTanga Joris, Nov 5, 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.