zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Cc: Matthew Martin <phy1729@gmail.com>, Oliver Kiddle <okiddle@yahoo.co.uk>
Subject: [PATCH] _git: Autocomplete .. for commit ranges
Date: Wed, 18 Nov 2015 23:15:41 +0000	[thread overview]
Message-ID: <20151118231541.GH2070@tarsus.local2> (raw)

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 )


                 reply	other threads:[~2015-11-18 23:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20151118231541.GH2070@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=okiddle@yahoo.co.uk \
    --cc=phy1729@gmail.com \
    --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).