summaryrefslogtreecommitdiff
path: root/contrib/completion
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2020-10-28 02:07:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-10-28 21:30:59 (GMT)
commit9a397ea5ad59e64ff6eebfd1d7dad43aac790e0a (patch)
tree751d421c9133cdf639c35d7112282e850f6b0fd1 /contrib/completion
parent46af9b371929c3c3c9cc0f5b4aa9bcb3089e6405 (diff)
downloadgit-9a397ea5ad59e64ff6eebfd1d7dad43aac790e0a.zip
git-9a397ea5ad59e64ff6eebfd1d7dad43aac790e0a.tar.gz
git-9a397ea5ad59e64ff6eebfd1d7dad43aac790e0a.tar.bz2
completion: zsh: refactor command completion
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/completion')
-rw-r--r--contrib/completion/git-completion.zsh20
1 files changed, 16 insertions, 4 deletions
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 60efddb..858864f 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -134,20 +134,32 @@ __gitcomp_file_direct ()
__gitcomp_file "$1" ""
}
+__git_complete_command ()
+{
+ emulate -L zsh
+
+ local command="$1"
+ local completion_func="_git_${command//-/_}"
+ if (( $+functions[$completion_func] )); then
+ emulate ksh -c $completion_func
+ return 0
+ else
+ return 1
+ fi
+}
+
__git_zsh_bash_func ()
{
emulate -L ksh
local command=$1
- local completion_func="_git_${command//-/_}"
- declare -f $completion_func >/dev/null && $completion_func && return
+ __git_complete_command "$command" && return
local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then
words[1]=$expansion
- completion_func="_git_${expansion//-/_}"
- declare -f $completion_func >/dev/null && $completion_func
+ __git_complete_command "$expansion"
fi
}