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 <redacted>
Signed-off-by: Tanga Joris <redacted>
---
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