From: Felipe Contreras <felipe.contreras@gmail.com>
To: David Aguilar <davvid@gmail.com>, Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
"Felipe Contreras" <felipe.contreras@gmail.com>,
"Denton Liu" <liu.denton@gmail.com>,
"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: RE: [PATCH v3] contrib/completion: fix zsh completion regression from 59d85a2a05
Date: Tue, 01 Jun 2021 14:15:02 -0500 [thread overview]
Message-ID: <60b6873624c6f_1a702085e@natae.notmuch> (raw)
In-Reply-To: <20210601165254.18136-1-davvid@gmail.com>
David Aguilar wrote:
> A recent change to make git-completion.bash use $__git_cmd_idx
> Add "git" to the "words" array in _git_zsh_main to guarantee
> that "git" is at least always in the completion list.
Hm, no. The current code already guarantees "git" is always at the start
of the completion list. In [1] I suggested to add git *if* $words is
used instead of $orig_words.
If you add "git" to $orig_words you end up with something like
"git git mv", so the __git_cmd_idx is definitely not 1.
You should probably try to test yourself:
words=( git ${words[@]} )
echo "$words" >> /tmp/words-log.txt
The problem is that zsh's _arguments eats all the words it finds, so for
example if you type:
git mv --force <tab>
$words will be 'mv --force'.
It's better to use $words because in case there's arguments beforehand,
like:
git --git-dir=/tmp/test/.git mv --force
$words will be 'mv --force', so we can get the proper index by just
adding 'git' beforehand.
But it doesn't work for arguments not in _arguments, like:
git --foo mv --force
Which returns:
--foo mv --force
And unfortunately upstream's version of the wrapper doesn't understand
many arguments, like -c, or -C. git-completion does have all of them
It's better to just leave the code as it is and just fix the regression
by adding __git_cmd_idx=1.
> Helped-by: Felipe Contreras <felipe.contreras@gmail.com>
I mean I kind of wrote 2 of the 3 lines you sent, can I get a
Suggested-by?
> --- a/contrib/completion/git-completion.zsh
> +++ b/contrib/completion/git-completion.zsh
> @@ -251,7 +251,7 @@ __git_zsh_main ()
> done
> ;;
> (arg)
> - local command="${words[1]}" __git_dir
> + local command="${words[1]}" __git_dir __git_cmd_idx=1
This is needed.
>
> if (( $+opt_args[--bare] )); then
> __git_dir='.'
> @@ -261,7 +261,7 @@ __git_zsh_main ()
>
> (( $+opt_args[--help] )) && command='help'
>
> - words=( ${orig_words[@]} )
> + words=( git ${orig_words[@]} )
This is wrong. The current code is fine.
Cheers.
[1] https://lore.kernel.org/git/60b3c2d7557bd_be762089a@natae.notmuch/
--
Felipe Contreras
next prev parent reply other threads:[~2021-06-01 19:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-01 16:52 [PATCH v3] contrib/completion: fix zsh completion regression from 59d85a2a05 David Aguilar
2021-06-01 19:15 ` Felipe Contreras [this message]
2021-06-01 20:59 ` David Aguilar
2021-06-01 23:33 ` Felipe Contreras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60b6873624c6f_1a702085e@natae.notmuch \
--to=felipe.contreras@gmail.com \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=liu.denton@gmail.com \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).