Permalink
Browse files

completion: fix completion of certain aliases

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 come 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>
  • Loading branch information...
1 parent 026addf commit b7b6be72d60d5d5fc308a0bb7d48508ff70f3998 @felipec committed Nov 5, 2013
Showing with 2 additions and 0 deletions.
  1. +1 −0 contrib/completion/git-completion.bash
  2. +1 −0 contrib/completion/git-completion.zsh
@@ -2555,6 +2555,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
@@ -96,6 +96,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

0 comments on commit b7b6be7

Please sign in to comment.