Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: RFC: [PATCH] Completion/Unix/Command/_git: replace a few "*::" with "*:"
- X-seq: zsh-workers 44081
- From: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- To: dana <dana@xxxxxxx>
- Subject: Re: RFC: [PATCH] Completion/Unix/Command/_git: replace a few "*::" with "*:"
- Date: Mon, 25 Feb 2019 10:46:03 +0100
- Autocrypt: addr=genml+zsh-workers@xxxxxxxxxx; prefer-encrypt=mutual; keydata= mQGiBD8qj1kRBADEu95hD1Vv3GOIAsmxWMdWwM3acuDfFdRMX/7mB84yU3/GzC4aRCDi/ZS9 3dQgM9gInU1IrrXQrDCWzMzRR4e/9/1aIwUGI1tWzulfae5NphVMQLtwH9tuqAXCo8HrdS+l BccHK16KflMfIr4HHhANeO+52oRa459LxsFkXghJEwCg/4IpXFnmzREFiRPToiUiOeJvej8E AJMqdc/2XeERJ0R7ZOtp7Md+P+JGsgbSgGEttVzDWSZq5sg9XZxhy+qxr+IH4AaTYc0ZPDEp ba1fKyiU9ksrNVJCoj9cJpLZ6DexQ6bDttLXBXIf17Yk4tYjvIpGEW3un+xz+XyDgnQ8cryY +i3EGgRnM2isYDaaJr49FhnwvMu0A/9VTaEqNBs2MgOFIkJ6/w8kvukYYma7DP0UeU7LXDfF 4Cr9lV3mQAb73Lzp1SEpWfVSAfxfU5ZAGiRhb3t6atzt7Kx07f6e7I5SeSAoksMX9QAiZO+1 bcJtKUYX2edrzSQwHhQkJdE7R+22II+DotobG1IG32938PWYhsplrZ3IebQeRGFuaWVsIEhh aGxlciA8cGdwQHRoZXF1b2QuZGU+iIEEExEKAEECGwMCHgECF4ACGQEFCwkIBwMFFQoJCAsF FgIDAQAWIQS1psIggp+uXWnrnKN8Ar+FP+Y+AAUCWWj1aQUJHgDNEAAKCRB8Ar+FP+Y+APZt AJ4mA1Db8pe/O5u1h6VdGgQKdjhXgQCg7+MICeEkTwseMpeey5kl1RTdudG5Ag0EPyqPahAI AOfwo/qJeURh5+1SN0stgMg6CjCYUHj+LATQu40Glvi3LIrf8nFjak2pS6txoSn0a/Lm/qDJ Lsb0AVLegaik/TKFR0bOYq+hMartBbnFVFLXlGLDMCDLaq2692a5VkobQtalbeCRRH1LsW7f Btx+g38F1M6uTf8aEZ6BUtCKgEiCB8ECpf1J9kePNSuD19llvfbbftjz4zz7fmniuRMYAe8J 87MkNWW9wyamhRZY+CGR3qSBDjyNebAKdJU1TLVNDXlxRMH6nmZD3iy/1TboRBBj0hgP5kfN JxomARDTW4X9QTqK+jsOxJnDdUbovmOp2lAObeVMN2Y5YONqbU6D5xcAAgIH/1q+1u4eqgW8 F2viyhqZGC02f/Hjyecx0HNhmFOD+XXdaUEo5ja/DZ/SRJTC17m2gV3ayYPnZeqSuvryhQ/S 2sRvubTAMNrjh3ZgJILjCoOLOqA+rKZBlTRHLgIC6g2K709p1H6ALBz59o2g65CwN4d6a1Z/ yYx9YxvbW6p5iOwQQ8sONSIgdGCxbQhLS5Ibv4eSa4oeNl2VTZ7XjJn2s/CeV5VkmtlokhjP Unr3mM8KSLqr7ztUBz9DUyquT7ccii6oYeG5z/YTBaHSLzFpP2IRZcuzPLFG4jzwX/Jd5+Yt 0kO4p5/NYUIf+kHlC7hipfFn498PIdzMarw9esnm/8iIYwQYEQoAIxYhBLWmwiCCn65daeuc o3wCv4U/5j4ABQJZaPWNBQkeAM0jAAoJEHwCv4U/5j4Aya0AoJijb+Unark3DdnQ8tcU/DqL 7gPiAJ9pZ+l/o6351Qq8Xna8dWnGIUKVxw==
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-type:content-type:in-reply-to:mime-version:user-agent :date:date:message-id:from:from:references:subject:subject :received:received; s=postfix2; t=1551087964; bh=ysQRGXYWRF4iXDw rxJogBAnO53X3DdikObIyvWsvDaE=; b=ngpGYtErh0YAdR7INFoP7jN4CHXVk11 Usff3HaPy6WuZ2gIe3e57toCtUHSl0h8Pb5VTi9NVZFQHHTGkAfoeYCeHs5Ynw8d hwR8qBCBZEKu1WbXx5W7iSIfLUU8fC1fQwNx0HPvIFkxjROHPeQheCb6v7Sv6WPD zjlODtOYmkyg=
- In-reply-to: <57F7B086-B935-4E12-8FEA-A2F232EEDB43@dana.is>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Openpgp: preference=signencrypt
- References: <20190224135854.3905-1-genml+zsh-workers@thequod.de> <57F7B086-B935-4E12-8FEA-A2F232EEDB43@dana.is>
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:
signature.asc
Description: OpenPGP digital signature
Messages sorted by:
Reverse Date,
Date,
Thread,
Author