[Outreachy PATCH v4 3/3] t0012: catch builtins that keep NO_PARSEOPT after conversion
- From
- Tanga 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