summaryrefslogtreecommitdiff
path: root/contrib/completion
diff options
context:
space:
mode:
authorLibravatar Nguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-03-24 21:35:21 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-03-25 09:33:45 -0700
commit48e1c69ade27395dfe7eb2be8aadf5fc50576a21 (patch)
tree374565e81755da0bba8ad1e677da25ed5a08d6c8 /contrib/completion
parentcompletion: mention the oldest version we need to support (diff)
downloadtgif-48e1c69ade27395dfe7eb2be8aadf5fc50576a21.tar.xz
completion: factor out _git_xxx calling code
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/completion')
-rw-r--r--contrib/completion/git-completion.bash17
1 files changed, 13 insertions, 4 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index d59b9bb4d8..4aaec3cd40 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3035,6 +3035,17 @@ _git_worktree ()
fi
}
+__git_complete_command () {
+ local command="$1"
+ local completion_func="_git_${command//-/_}"
+ if declare -f $completion_func >/dev/null 2>/dev/null; then
+ $completion_func
+ return 0
+ else
+ return 1
+ fi
+}
+
__git_main ()
{
local i c=1 command __git_dir __git_repo_path
@@ -3094,14 +3105,12 @@ __git_main ()
return
fi
- local completion_func="_git_${command//-/_}"
- declare -f $completion_func >/dev/null 2>/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 2>/dev/null && $completion_func
+ __git_complete_command "$expansion"
fi
}