completion: fix completing args of aliased "push", "fetch", etc.
Some commands need the first word to determine the actual action that is being executed, however, the command is wrong when we use an alias, for example 'alias.p=push', if we try to complete 'git p origin ', the result would be wrong because __git_complete_remote_or_refspec() doesn't know where it came from. So let's override words[1], so the alias 'p' is override by the actual command, 'push'. Reported-by: Aymeric Beaumet <aymeric.beaumet@gmail.com> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 9, 2014 at 13:50 UTC
880111c11befaaf070e8ea1021bf11b4fb58c461
2 files changed
+2
contrib/completion/git-completion.bash
+1
@@ -2564,6 +2564,7 @@ __git_main ()
2564
2565
local expansion=$(__git_aliased_command "$command")
2566
if [ -n "$expansion" ]; then
2567
+ words[1]=$expansion
2568
completion_func="_git_${expansion//-/_}"
2569
declare -f $completion_func >/dev/null && $completion_func
2570
fi
contrib/completion/git-completion.zsh
+1
@@ -104,6 +104,7 @@ __git_zsh_bash_func ()
104
105
local expansion=$(__git_aliased_command "$command")
106
if [ -n "$expansion" ]; then
107
+ words[1]=$expansion
108
completion_func="_git_${expansion//-/_}"
109
declare -f $completion_func >/dev/null && $completion_func
110
fi