All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] contrib/completion: fix remote completion for "git push/remote"
@ 2021-05-30  2:49 David Aguilar
  2021-05-30  3:12 ` Eric Sunshine
  0 siblings, 1 reply; 3+ messages in thread
From: David Aguilar @ 2021-05-30  2:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Felipe Contreras, Denton Liu, SZEDER Gábor

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.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
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(+)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index d51ff5302d..bc1aea82bf 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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
-- 
2.32.0.rc2.2.ga063d53b1a


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] contrib/completion: fix remote completion for "git push/remote"
  2021-05-30  2:49 [PATCH] contrib/completion: fix remote completion for "git push/remote" David Aguilar
@ 2021-05-30  3:12 ` Eric Sunshine
  2021-05-30  3:32   ` David Aguilar
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sunshine @ 2021-05-30  3:12 UTC (permalink / raw)
  To: David Aguilar
  Cc: Junio C Hamano, Git List, Felipe Contreras, Denton Liu,
	SZEDER Gábor

On Sat, May 29, 2021 at 10:49 PM David Aguilar <davvid@gmail.com> wrote:
> If __git_cmd_idx is empty then zsh will silelntly fail to
> complete remotes when doing "git push <tab>".

s/silelntly/silently/

> 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.
>
> Signed-off-by: David Aguilar <davvid@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] contrib/completion: fix remote completion for "git push/remote"
  2021-05-30  3:12 ` Eric Sunshine
@ 2021-05-30  3:32   ` David Aguilar
  0 siblings, 0 replies; 3+ messages in thread
From: David Aguilar @ 2021-05-30  3:32 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Junio C Hamano, Git List, Felipe Contreras, Denton Liu,
	SZEDER Gábor

On Sat, May 29, 2021 at 8:12 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Sat, May 29, 2021 at 10:49 PM David Aguilar <davvid@gmail.com> wrote:
> > If __git_cmd_idx is 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)
-- 
David

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-30  3:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-30  2:49 [PATCH] contrib/completion: fix remote completion for "git push/remote" David Aguilar
2021-05-30  3:12 ` Eric Sunshine
2021-05-30  3:32   ` David Aguilar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.