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

PATCH: _git: improve the way git aliases are fed into a hash



+ doesn't mess with IFS
+ uses a proper regular expression for --get-regex
+ uses _call_program
+ does not break if, for some reason, the _call_program call returns
  an odd number of lines (which associative array assignments don't
  like).


Index: Completion/Unix/Command/_git
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
retrieving revision 1.101
diff -u -r1.101 _git
--- Completion/Unix/Command/_git	2 Sep 2008 18:04:54 -0000	1.101
+++ Completion/Unix/Command/_git	5 Sep 2008 17:45:21 -0000
@@ -4272,11 +4272,12 @@
 # fun with $words[] and $CURRENT to enable completion for args
 # to git aliases (eg. git co <TAB>)
 local -A git_aliases
-# TODO: filling git_aliases like this is ugly. I didn't get it working elegantly.
-local oifs=$IFS
-IFS=$'\0'
-git_aliases=(${=${(0)${(@)${${${(f)"$(git config --get-regexp alias.\*)"}/(#s)alias./}/ /$'\0'}}}})
-IFS=$oifs ; unset oifs
+local -a git_aliases__
+git_aliases__=(${(f)${${${(f)"$(_call_program alias_expansion git config --get-regexp '\^alias\.')"}#alias.}/ /$'\n'}/(#e)/$'\n'})
+if (( ( ${#git_aliases__} % 2 ) == 0 )) ; then
+    git_aliases=(${git_aliases__})
+fi
+unset git_aliases__
 
 if (( CURRENT >= 3 )) && [[ -n ${git_aliases[$words[2]]} ]] ; then
   local -a tmpwords expalias



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