{"thread":{"id":"55800","subject":"[PATCH] contrib/completion: fix remote completion for \"git push/remote\"","startedAt":"2021-05-30T03:05:58Z","lastAt":"2021-05-30T03:42:41Z","messageCount":3,"participants":["David Aguilar","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"425895","messageId":"20210530024928.24158-1-davvid@gmail.com","threadId":"55800","inReplyTo":null,"subject":"[PATCH] contrib/completion: fix remote completion for \"git push/remote\"","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2021-05-30T02:49:28Z","receivedAt":"2021-05-30T03:05:58Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"If __git_cmd_idx is empty then zsh will silelntly fail to\ncomplete remotes when doing \"git push <tab>\".\n\nEnsure that __git_cmd_idx is non-empty before using it in\n__git_complete_remote_or_refspec.\n\nThis was tested on zsh 5.7.1 (x86_64-apple-darwin19.0).\nOther versions of zsh, eg. zsh 5.0.2 (x86_64-redhat-linux-gnu),\ndo not exhibit this behavior.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nFurther testing of the completion behavior spotted this regression.\n\nThis should be applied on top of,\n\"contrib/completion: avoid empty arithemetic expressions\".\nand could arguably be squashed into that commit.\n\nI have my zshrc setup to point directly to a git.git worktree and a recent\nupdate seems to have caused these regressions.\n\n contrib/completion/git-completion.bash | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex d51ff5302d..bc1aea82bf 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1006,6 +1006,9 @@ __git_complete_revlist ()\n \n __git_complete_remote_or_refspec ()\n {\n+\tif [ -z \"$__git_cmd_idx\" ]; then\n+\t\t__git_cmd_idx=1\n+\tfi\n \tlocal cur_=\"$cur\" cmd=\"${words[__git_cmd_idx]}\"\n \tlocal i c=$((__git_cmd_idx+1)) remote=\"\" pfx=\"\" lhs=1 no_complete_refspec=0\n \tif [ \"$cmd\" = \"remote\" ]; then\n-- \n2.32.0.rc2.2.ga063d53b1a\n\n"},{"id":"425896","messageId":"CAPig+cTOFySGeUKM2oa9nHmkGVaWUbq8ghcid0hHxxSbV6jAjg@mail.gmail.com","threadId":"55800","inReplyTo":"20210530024928.24158-1-davvid@gmail.com","subject":"Re: [PATCH] contrib/completion: fix remote completion for \"git push/remote\"","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-05-30T03:12:06Z","receivedAt":"2021-05-30T03:12:43Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sat, May 29, 2021 at 10:49 PM David Aguilar <davvid@gmail.com> wrote:\n> If __git_cmd_idx is empty then zsh will silelntly fail to\n> complete remotes when doing \"git push <tab>\".\n\ns/silelntly/silently/\n\n> Ensure that __git_cmd_idx is non-empty before using it in\n> __git_complete_remote_or_refspec.\n>\n> This was tested on zsh 5.7.1 (x86_64-apple-darwin19.0).\n> Other versions of zsh, eg. zsh 5.0.2 (x86_64-redhat-linux-gnu),\n> do not exhibit this behavior.\n>\n> Signed-off-by: David Aguilar <davvid@gmail.com>\n"},{"id":"425897","messageId":"CAJDDKr4rVLYxPpwEg3K4Ok1XUeKhupthPehyKczhHYmFFMF_0Q@mail.gmail.com","threadId":"55800","inReplyTo":"CAPig+cTOFySGeUKM2oa9nHmkGVaWUbq8ghcid0hHxxSbV6jAjg@mail.gmail.com","subject":"Re: [PATCH] contrib/completion: fix remote completion for \"git push/remote\"","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2021-05-30T03:32:30Z","receivedAt":"2021-05-30T03:42:41Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sat, May 29, 2021 at 8:12 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> On Sat, May 29, 2021 at 10:49 PM David Aguilar <davvid@gmail.com> wrote:\n> > If __git_cmd_idx is empty then zsh will silelntly fail to\n> > complete remotes when doing \"git push <tab>\".\n>\n> s/silelntly/silently/\n\n\nThanks! I'm going to wait a bit for the completion experts to chime in\nbefore I prepare a v2.\n\nFor v2, I'm thinking it might make sense to go ahead and squash both\nof the completion changes into a single patch.\n\n(sorry for the noisy resend -- I wasn't in text mode so vger dropped\nthe original reply)\n-- \nDavid\n"}]}