]> git.ipfire.org Git - thirdparty/git.git/commitdiff
contrib/completion: fix zsh completion regression from 59d85a2a05
authorDavid Aguilar <davvid@gmail.com>
Tue, 1 Jun 2021 20:52:29 +0000 (13:52 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Jun 2021 03:49:40 +0000 (12:49 +0900)
A recent change to make git-completion.bash use $__git_cmd_idx
in more places broke a number of completions on zsh because it
modified __git_main but did not update __git_zsh_main.

Notably, completions for "add", "branch", "mv" and "push" were
broken as a result of this change.

In addition to the undefined variable usage, "git mv <tab>" also
prints the following error:

__git_count_arguments:7: bad math expression:
operand expected at `"1"'

_git_mv:[:7: unknown condition: -gt

Remove the quotes around $__git_cmd_idx in __git_count_arguments
and set __git_cmd_idx=1 early in __git_zsh_main to fix the
regressions from 59d85a2a05.

This was tested on zsh 5.7.1 (x86_64-apple-darwin19.0).

Suggested-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Acked-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 3c5739b9059a20bd90bee8664ccdfd737a2787da..b50c5d0ea3867bd5def9865efa626af25d4567b1 100644 (file)
@@ -1306,7 +1306,7 @@ __git_count_arguments ()
        local word i c=0
 
        # Skip "git" (first argument)
-       for ((i="$__git_cmd_idx"; i < ${#words[@]}; i++)); do
+       for ((i=$__git_cmd_idx; i < ${#words[@]}; i++)); do
                word="${words[i]}"
 
                case "$word" in
index 6c56296997f939cf6c46719c4efbc2305211e9ee..cac6f61881734c0b046c8e9abe71cc608209a511 100644 (file)
@@ -251,7 +251,7 @@ __git_zsh_main ()
                done
                ;;
        (arg)
-               local command="${words[1]}" __git_dir
+               local command="${words[1]}" __git_dir __git_cmd_idx=1
 
                if (( $+opt_args[--bare] )); then
                        __git_dir='.'