* PATCH: _git: improve the way git aliases are fed into a hash
@ 2008-09-05 17:54 Frank Terbeck
0 siblings, 0 replies; only message in thread
From: Frank Terbeck @ 2008-09-05 17:54 UTC (permalink / raw)
To: zsh workers
+ 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-09-05 19:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-05 17:54 PATCH: _git: improve the way git aliases are fed into a hash Frank Terbeck
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).