Skip to content

Commit

Permalink
completion: fix completing args of aliased "push", "fetch", etc.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Felipe Contreras authored and gitster committed Apr 9, 2014
1 parent 68773ac commit 880111c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/completion/git-completion.bash
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions contrib/completion/git-completion.zsh
Expand Up @@ -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
Expand Down

0 comments on commit 880111c

Please sign in to comment.