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>
This commit is contained in:

committed by
Junio C Hamano

parent
d23bb387ae
commit
48e1c69ade
@ -3035,6 +3035,17 @@ _git_worktree ()
|
|||||||
fi
|
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 ()
|
__git_main ()
|
||||||
{
|
{
|
||||||
local i c=1 command __git_dir __git_repo_path
|
local i c=1 command __git_dir __git_repo_path
|
||||||
@ -3094,14 +3105,12 @@ __git_main ()
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local completion_func="_git_${command//-/_}"
|
__git_complete_command "$command" && return
|
||||||
declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return
|
|
||||||
|
|
||||||
local expansion=$(__git_aliased_command "$command")
|
local expansion=$(__git_aliased_command "$command")
|
||||||
if [ -n "$expansion" ]; then
|
if [ -n "$expansion" ]; then
|
||||||
words[1]=$expansion
|
words[1]=$expansion
|
||||||
completion_func="_git_${expansion//-/_}"
|
__git_complete_command "$expansion"
|
||||||
declare -f $completion_func >/dev/null 2>/dev/null && $completion_func
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user