From: Daniel Hahler <genml+zsh-workers@thequod.de>
To: dana <dana@dana.is>
Cc: zsh-workers@zsh.org
Subject: Re: RFC: [PATCH] Completion/Unix/Command/_git: replace a few "*::" with "*:"
Date: Mon, 25 Feb 2019 10:46:03 +0100 [thread overview]
Message-ID: <fdcdec23-2ff0-24df-9d1c-3a7f432a7da6@gmail.com> (raw)
In-Reply-To: <57F7B086-B935-4E12-8FEA-A2F232EEDB43@dana.is>
[-- Attachment #1.1: Type: text/plain, Size: 2894 bytes --]
On 24.02.19 20:46, dana wrote:
>> This patch changes some of the "*::" to "*:", but is not really tested
>> in detail. Mostly based on trying if "--help" worked after any arg.
>
> Some of these do look like they were just erroneously copied and pasted, but
> in other cases it's actually necessary, at least with the way it's written
> now. For example, the commit-range-or-file state checks to see if $CURRENT is
> 1, which can only ever be true if the *:: syntax (or equivalent) is used.
I see, thanks for looking into it!
Unfortunately this also affects / is true for state
branch-or-tree-ish-or-file with _git-checkout already, which I've wanted
to fix in the first place.
Can this be fixed in a different way then?
Currently it just returns:
case $state in
(branch-or-tree-ish-or-file)
# TODO: Something about *:: brings us here when we complete at "-". I
# guess that this makes sense in a way, as we might want to treat it as
# an argument, but I can't find anything in the documentation about this
# behavior.
[[ $line[CURRENT] = -* ]] && return
What about something like this (against master)?
diff --git i/Completion/Unix/Command/_git w/Completion/Unix/Command/_git
index b3e54f7f9..c134f13b8 100644
--- i/Completion/Unix/Command/_git
+++ w/Completion/Unix/Command/_git
@@ -449,7 +449,8 @@ _git-checkout () {
local curcontext=$curcontext state line ret=1
declare -A opt_args
- _arguments -C -s \
+ local -a options
+ options=(
'(-q --quiet --progress)'{-q,--quiet}'[suppress progress reporting]' \
'(-f --force -m --merge --conflict --patch)'{-f,--force}'[force branch switch/ignore unmerged entries]' \
'(-q --quiet -2 --ours -3 --theirs --patch)'{-2,--ours}'[check out stage #2 for unmerged paths]' \
@@ -469,6 +470,9 @@ _git-checkout () {
'--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \
'(-q --quiet)--progress[force progress reporting]' \
'(-)--[start file arguments]' \
+ )
+
+ _arguments -C -s $options \
'*:: :->branch-or-tree-ish-or-file' && ret=0
case $state in
@@ -477,7 +481,7 @@ _git-checkout () {
# guess that this makes sense in a way, as we might want to treat it as
# an argument, but I can't find anything in the documentation about this
# behavior.
- [[ $line[CURRENT] = -* ]] && return
+ _arguments -C -s $options && ret=0 && return
if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then
# TODO: Allow A...B
local \
> I didn't look at it much harder than that, but, in general, anywhere you're
> thinking about removing *:: or *:::, you need to check the corresponding state
> code to see if it does anything with $words or $CURRENT, or calls another
> function that does.
>
> dana
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2019-02-25 9:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-24 13:58 Daniel Hahler
2019-02-24 19:46 ` dana
2019-02-25 9:46 ` Daniel Hahler [this message]
2019-02-25 10:04 ` Daniel Hahler
2019-02-25 19:14 ` dana
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=fdcdec23-2ff0-24df-9d1c-3a7f432a7da6@gmail.com \
--to=genml+zsh-workers@thequod.de \
--cc=dana@dana.is \
--cc=zsh-workers@zsh.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).