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

PATCH: partly rewriting alias handling in _git



While the last patch (zw25561) in that field did improve the handling
of git aliases, it also drew my attention to other problems in the
code.

I've been playing with this version for some time and AFAICS it
handles most cases quite well (a lot better than the old one).

Another thing, I didn't address in this patch is this:
    % git c  --some args
           ^- place the cursor here and hit <tab>.

That does not return completions like 'commit'.

If, later in the code (at the end before the last 'case'), you
replace "'*::options:->options' && ret=0" with
        "'*:options:->options' && ret=0", it starts to work.

I'm not sure if I am missing something and the two-colon form was used
on purpose.

Anyway, as for git alias handling:

Index: Completion/Unix/Command/_git
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
retrieving revision 1.95
diff -u -r1.95 _git
--- Completion/Unix/Command/_git	31 Aug 2008 16:09:08 -0000	1.95
+++ Completion/Unix/Command/_git	1 Sep 2008 18:02:55 -0000
@@ -4285,16 +4285,16 @@
 IFS=$oifs ; unset oifs
 
 if (( CURRENT >= 3 )) && [[ -n ${git_aliases[$words[2]]} ]] ; then
-  local -a tmpwords
-  tmpwords=(${words[1]} ${(z)git_aliases[$words[2]]})
-  if [[ -z "${words[3,-1]}" ]] ; then
-      tmpwords[$(( ${#tmpwords} + 1 ))]=""
-  else
+  local -a tmpwords expalias
+  expalias=(${(z)git_aliases[$words[2]]})
+  tmpwords=(${words[1]} ${expalias})
+  if [[ -n "${words[3,-1]}" ]] ; then
       tmpwords+=(${words[3,-1]})
   fi
+  tmpwords+=('')
+  (( CURRENT += ${#expalias} - 1 ))
   words=("${tmpwords[@]}")
-  (( CURRENT += ${#${(z)git_aliases[$words[2]]}} - 1 ))
-  unset tmpwords
+  unset tmpwords expalias
 fi
 
 if [[ $service == git ]]; then



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