{"thread":{"id":"56292","subject":"[PATCH] completion: fix __git_cmd_idx regression for zsh","startedAt":"2021-08-16T09:19:49Z","lastAt":"2021-08-16T09:19:49Z","messageCount":1,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"432791","messageId":"20210816091935.548555-1-felipe.contreras@gmail.com","threadId":"56292","inReplyTo":null,"subject":"[PATCH] completion: fix __git_cmd_idx regression for zsh","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-08-16T09:19:35Z","receivedAt":"2021-08-16T09:19:49Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The commit 59d85a2a05 (git-completion.bash: use $__git_cmd_idx in more\nplaces, 2021-04-22) caused a regression when using __git_complete and a\ncommand relies on __git_cmd_idx. This was fixed in cea232194d\n(completion: bash: fix late declaration of __git_cmd_idx, 2021-06-18)\nbut only for bash.\n\nWe need the function wrapper (__git_func_wrap in bash and _git in zsh)\nto define __git_cmd_idx.\n\nOtherwise the equivalent of __git_complete in zsh fails:\n\n  compdef _git ga=git_add\n  ga <tab>\n  ga __git_find_on_cmdline:[:14: unknown condition: -lt\n\nReported-by: Harrison McCullough <mccullough.harrison@gmail.com>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n\nI had already sent the correct fix [1], but Junio decided to pick\nsomebody else's patch, therefore the regression is still present for\nzsh.\n\n[1] https://lore.kernel.org/git/20210618185832.700477-1-felipe.contreras@gmail.com/\n\n contrib/completion/git-completion.zsh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex cac6f61881..a1f2d27817 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -271,7 +271,7 @@ __git_zsh_main ()\n _git ()\n {\n \tlocal _ret=1\n-\tlocal cur cword prev\n+\tlocal cur cword prev __git_cmd_idx=0\n \n \tcur=${words[CURRENT]}\n \tprev=${words[CURRENT-1]}\n-- \n2.32.0.48.g096519100f\n\n"}]}