Skip to contentSkip to conversation

completion: fix __git_cmd_idx regression for zsh

PATCH New Felipe Contreras 1 participant 1 message Aug 16, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 completion: fix __git_cmd_idx regression for zsh

The commit 59d85a2a05 (git-completion.bash: use $__git_cmd_idx in more places, 2021-04-22) caused a regression when using __git_complete and a command relies on __git_cmd_idx. This was fixed in cea232194d (completion: bash: fix late declaration of __git_cmd_idx, 2021-06-18) but only for bash.

We need the function wrapper (__git_func_wrap in bash and _git in zsh) to define __git_cmd_idx.

Otherwise the equivalent of __git_complete in zsh fails:

compdef _git ga=git_add
ga <tab>
ga __git_find_on_cmdline:[:14: unknown condition: -lt

---

I had already sent the correct fix [1], but Junio decided to pick somebody else's patch, therefore the regression is still present for zsh.

[1] https://lore.kernel.org/git/[email protected]/

 contrib/completion/git-completion.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/completion/git-completion.zsh +1 -1
index cac6f61881..a1f2d27817 100644
@@ -271,7 +271,7 @@ __git_zsh_main ()
 _git ()
 {
 	local _ret=1
-	local cur cword prev
+	local cur cword prev __git_cmd_idx=0
 
 	cur=${words[CURRENT]}
 	prev=${words[CURRENT-1]}
Signature · 1 line
2.32.0.48.g096519100f