diff mbox series

[22/51] completion: zsh: fix for undefined completions

Message ID 20220830093138.1581538-23-felipe.contreras@gmail.com (mailing list archive)
State New, archived
Headers show
Series completion: revamp | expand

Commit Message

Felipe Contreras Aug. 30, 2022, 9:31 a.m. UTC
The parseopt helper can generate the completions even if the function is
unspecified.

  git version --<tab>

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.zsh | 3 +++
 t/t9904-zsh-completion.sh             | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index e771a2a53a..30607aa93d 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -141,6 +141,9 @@  __git_complete_command ()
 	if (( $+functions[$completion_func] )); then
 		emulate ksh -c $completion_func
 		return 0
+	elif emulate ksh -c "__git_support_parseopt_helper $command"; then
+		emulate ksh -c "__git_complete_common $command"
+		return 0
 	else
 		return 1
 	fi
diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh
index cd223b6e2a..14f5e5d9b8 100755
--- a/t/t9904-zsh-completion.sh
+++ b/t/t9904-zsh-completion.sh
@@ -1015,7 +1015,7 @@  test_expect_success 'completion used <cmd> completion for alias: !f() { : git <c
 	EOF
 '
 
-test_expect_failure 'completion without explicit _git_xxx function' '
+test_expect_success 'completion without explicit _git_xxx function' '
 	test_completion "git version --" <<-\EOF
 	--build-options Z
 	--no-build-options Z