Browse Source

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>
maint
Felipe Contreras 11 years ago committed by Junio C Hamano
parent
commit
880111c11b
  1. 1
      contrib/completion/git-completion.bash
  2. 1
      contrib/completion/git-completion.zsh

1
contrib/completion/git-completion.bash

@ -2564,6 +2564,7 @@ __git_main () @@ -2564,6 +2564,7 @@ __git_main ()

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
fi

1
contrib/completion/git-completion.zsh

@ -104,6 +104,7 @@ __git_zsh_bash_func () @@ -104,6 +104,7 @@ __git_zsh_bash_func ()

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
fi

Loading…
Cancel
Save