Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _git: Autocomplete .. for commit ranges
- X-seq: zsh-workers 37150
 
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
 
- To: zsh-workers@xxxxxxx
 
- Subject: [PATCH] _git: Autocomplete .. for commit ranges
 
- Date: Wed, 18 Nov 2015 23:15:41 +0000
 
- Cc: Matthew Martin <phy1729@xxxxxxxxx>, Oliver Kiddle <okiddle@xxxxxxxxxxx>
 
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=	daniel.shahaf.name; h=cc:content-transfer-encoding:content-type	:date:from:message-id:mime-version:subject:to:x-sasl-enc	:x-sasl-enc; s=mesmtp; bh=jUx2CyJtL5cVmDnK6EHUhZxVLJk=; b=L3jUgR	Emax09WQWnjgukh3it/FJQPe6hfK0qv2eJxVB9+5+lfq9AW7AvkwmGiQpxk22JmV	3j3jq/O/+iIgVp7eApHRb0zFa2AQyvVPdP9yLZ8tx3AuXQFr1ErPrevKt8GJ1E46	eydrwpUsevtAFd6+EY6zj8ooJlMA+SZnYxtbw=
 
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=	messagingengine.com; h=cc:content-transfer-encoding:content-type	:date:from:message-id:mime-version:subject:to:x-sasl-enc	:x-sasl-enc; s=smtpout; bh=jUx2CyJtL5cVmDnK6EHUhZxVLJk=; b=DQD4Y	p2YbTMaGMwPzYT1AeJIietBCg1ZmQ0T2gOlXw2nSc0zTbQMZdWIa1sQBsU/1DPZz	HVRgSP5Ub91cPMeo5Wz7X+BdWKTfdZlxuAEb240kKH13y9d+zsCpLsHaosCtJQkG	zzpxva7PjF3zEd2DyseK+PcFrBfOJyPPay1utk=
 
- List-help: <mailto:zsh-workers-help@zsh.org>
 
- List-id: Zsh Workers List <zsh-workers.zsh.org>
 
- List-post: <mailto:zsh-workers@zsh.org>
 
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
 
This patch makes three changes:
- Enable 'git diff o/m<TAB>' to complete to 'origin/master..' with the
  ".." being autoremovable.
  This is implemented by the first hunk.  That hunk is a functional
  subset of Oliver's users/20705, however, the latter hasn't been
  committed.
- Make typing "^" remove the "..", in light of the syntax "foo^..bar".
- Make typing "." _not_ remove the ".." but simply append it, since
  "foo...bar" is a valid and useful syntax.
---
I'm not sure why the ^ needs escaping there — ^ is not special in character
classes when not in first position.
I think this can be further improved, for example, in 'git log
o/m<TAB>--' (for a 'git log HEAD -- file.c' syntax) typing the '-'
should remove the "..".
Cheers,
Daniel
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index ad1037e..ac3e152 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5597,8 +5597,8 @@ __git_commits () {
 
 (( $+functions[__git_heads] )) ||
 __git_heads () {
-  __git_heads_local
-  __git_heads_remote
+  __git_heads_local "$@"
+  __git_heads_remote "$@"
 }
 
 (( $+functions[__git_heads_local] )) ||
@@ -5786,7 +5786,7 @@ __git_commit_ranges () {
       if [[ ${PREFIX} = (#b)((\\|)\^)* ]]; then
 	compset -p ${#match[1]}
       else
-	suf=( -S .. -r '.@~ ^:\t\n\-' )
+	suf=( -S .. -r '@~ \^:\t\n\-' )
       fi
     fi
     expl=( $* $suf )
Messages sorted by:
Reverse Date,
Date,
Thread,
Author