]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: fix completing args of aliased "push", "fetch", etc.
authorFelipe Contreras <felipe.contreras@gmail.com>
Wed, 9 Apr 2014 18:50:04 +0000 (13:50 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Apr 2014 21:22:18 +0000 (14:22 -0700)
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>
contrib/completion/git-completion.bash
contrib/completion/git-completion.zsh

index 87de809d23146c2cee818555028cf8a24dc6c908..2c59a76bc2cf2d0fefb633efe805b6c7c15ad7ec 100644 (file)
@@ -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
index 6b779685722916f8032dce9b3b46220eb6a19414..9f6f0fa5581002a2371e062fd5def0978733edc1 100644 (file)
@@ -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