Skip to content

Commit 880111c

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68773ac commit 880111c

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,7 @@ __git_main ()
25642564

25652565
local expansion=$(__git_aliased_command "$command")
25662566
if [ -n "$expansion" ]; then
2567+
words[1]=$expansion
25672568
completion_func="_git_${expansion//-/_}"
25682569
declare -f $completion_func >/dev/null && $completion_func
25692570
fi

contrib/completion/git-completion.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ __git_zsh_bash_func ()
104104

105105
local expansion=$(__git_aliased_command "$command")
106106
if [ -n "$expansion" ]; then
107+
words[1]=$expansion
107108
completion_func="_git_${expansion//-/_}"
108109
declare -f $completion_func >/dev/null && $completion_func
109110
fi

0 commit comments

Comments
 (0)