[PATCH 23/51] completion: zsh: add support for general -c opts
So we can specify configurations.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/completion/git-completion.zsh | 5 +++++
t/t9904-zsh-completion.sh | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 30607aa93d..b062090a13 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -231,6 +231,7 @@ __git_zsh_main ()
'--no-replace-objects[do not use replacement refs to replace git objects]' \
'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
'*-C[run as if git was started in the given path]: :_directories' \
+ '*-c[pass a configuration parameter to the command]: :->config' \
'(-): :->command' \
'(-)*:: :->arg' && return
@@ -244,6 +245,10 @@ __git_zsh_main ()
let _ret || break
done
;;
+ (config)
+ compset -P '*[=:]'
+ emulate ksh -c __git_complete_config_variable_name_and_value
+ ;;
(arg)
local command="${words[1]}" __git_dir __git_cmd_idx=1
diff --git a/t/t9904-zsh-completion.sh b/t/t9904-zsh-completion.sh
index 14f5e5d9b8..4c7cf4234e 100755
--- a/t/t9904-zsh-completion.sh
+++ b/t/t9904-zsh-completion.sh
@@ -1071,7 +1071,7 @@ test_expect_success 'git config - value' '
EOF
'
-test_expect_failure 'git -c - section' '
+test_expect_success 'git -c - section' '
test_completion "git -c br" <<-\EOF
branch.Z
browser.Z
@@ -1086,7 +1086,7 @@ test_expect_failure 'git -c - variable name' '
EOF
'
-test_expect_failure 'git -c - value' '
+test_expect_success 'git -c - value' '
test_completion "git -c color.pager=" <<-\EOF
false Z
true Z
--
2.37.2.351.g9bf691b78c.dirty