Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: (maybe) negative ranges

I'd like to be able to ignore ^ at the start of a git range
specification to support things like

  git log r1 ^r2

(which is useful as it saves me having to remember what .. and
... mean and getting infuriated because they mean the opposite for git

This being zsh, it's not as easy as it should be.  With extendedglob I
need to quote the ^ on the command line, which I'm doing with a

  git log r1 \^r<TAB>

In the completion function that gets executed as a result it looks like
$PREFIX still contains the backslash, so I have to deal with quoting
myself and still leave a valid revision to complete in further procesing.

This seems to do what I want, but I may have missed up to N! tricks...

I have no idea how to tweak this to turn


into the equivalent of having


in the bowels and


still on the command line, which looks like the only way of
consistently keeping the quotes and still have the completion work.


diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 40a9fb6..1fcde90 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5753,7 +5753,14 @@ __git_commit_ranges () {
   if compset -P '*..(.|)'; then
     expl=( $* )
-    compset -S '..*' || suf=( -S .. -r '.@~ ^:\t\n\-' )
+    if ! compset -S '..*'; then
+      local match mbegin mend
+      if [[ ${PREFIX} = (#b)((\\|)\^)* ]]; then
+	compset -p ${#match[1]}
+      else
+	suf=( -S .. -r '.@~ ^:\t\n\-' )
+      fi
+    fi
     expl=( $* $suf )

Messages sorted by: Reverse Date, Date, Thread, Author