contrib/completion: fix remote completion for "git push/remote"
PATCH 1/1 contrib/completion: fix remote completion for "git push/remote"
If __git_cmd_idx is empty then zsh will silelntly fail to complete remotes when doing "git push <tab>".
Ensure that __git_cmd_idx is non-empty before using it in __git_complete_remote_or_refspec.
This was tested on zsh 5.7.1 (x86_64-apple-darwin19.0). Other versions of zsh, eg. zsh 5.0.2 (x86_64-redhat-linux-gnu), do not exhibit this behavior.
---
Further testing of the completion behavior spotted this regression.
This should be applied on top of, "contrib/completion: avoid empty arithemetic expressions". and could arguably be squashed into that commit.
I have my zshrc setup to point directly to a git.git worktree and a recent update seems to have caused these regressions.
contrib/completion/git-completion.bash | 3 +++ 1 file changed, 3 insertions(+)
contrib/completion/git-completion.bash +3 -0
@@ -1006,6 +1006,9 @@ __git_complete_revlist () __git_complete_remote_or_refspec () { + if [ -z "$__git_cmd_idx" ]; then + __git_cmd_idx=1 + fi local cur_="$cur" cmd="${words[__git_cmd_idx]}" local i c=$((__git_cmd_idx+1)) remote="" pfx="" lhs=1 no_complete_refspec=0 if [ "$cmd" = "remote" ]; then
Signature · 1 line
2.32.0.rc2.2.ga063d53b1a
Quoted 2 lines · David Aguilar
If
__git_cmd_idxis empty then zsh will silelntly fail to complete remotes when doing "git push <tab>".
s/silelntly/silently/
Quoted 8 lines
Ensure that
__git_cmd_idxis non-empty before using it in__git_complete_remote_or_refspec.This was tested on zsh 5.7.1 (x86_64-apple-darwin19.0). Other versions of zsh, eg. zsh 5.0.2 (x86_64-redhat-linux-gnu), do not exhibit this behavior.
Signed-off-by David Aguilar <[email protected]>
Quoted 6 lines · Eric Sunshine
Quoted 2 lines · David Aguilar
If
__git_cmd_idxis empty then zsh will silelntly fail to complete remotes when doing "git push <tab>".s/silelntly/silently/
Thanks! I'm going to wait a bit for the completion experts to chime in before I prepare a v2.
For v2, I'm thinking it might make sense to go ahead and squash both of the completion changes into a single patch.
(sorry for the noisy resend -- I wasn't in text mode so vger dropped the original reply)
Signature · 1 line
David