From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5696 invoked from network); 5 Sep 2008 19:35:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 5 Sep 2008 19:35:47 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 57866 invoked from network); 5 Sep 2008 19:35:01 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 Sep 2008 19:35:01 -0000 Received: (qmail 1447 invoked by alias); 5 Sep 2008 19:34:44 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25624 Received: (qmail 1429 invoked from network); 5 Sep 2008 19:34:42 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 5 Sep 2008 19:34:42 -0000 Received: from mta-1.ms.rz.rwth-aachen.de (mta-1.ms.rz.RWTH-Aachen.DE [134.130.7.72]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 5DF79809A1AC for ; Fri, 5 Sep 2008 21:34:23 +0200 (CEST) Received: from ironport-out-1.rz.rwth-aachen.de ([134.130.3.58]) by mta-1.ms.rz.RWTH-Aachen.de (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTP id <0K6Q007OHHS1CH10@mta-1.ms.rz.RWTH-Aachen.de> for zsh-workers@sunsite.dk; Fri, 05 Sep 2008 19:55:13 +0200 (CEST) Received: from relay-1.ms.rz.rwth-aachen.de (HELO relay.rwth-aachen.de) ([134.130.7.74]) by ironport-in-1.rz.rwth-aachen.de with ESMTP; Fri, 05 Sep 2008 19:55:13 +0200 Received: from fsst.voodoo.lan ([212.117.84.140]) by relay.rwth-aachen.de (8.13.8+Sun/8.13.8/1) with ESMTP id m85HtC7Q012295 for ; Fri, 05 Sep 2008 19:55:13 +0200 (CEST) Received: from hawk by fsst.voodoo.lan with local (Exim 4.69) (envelope-from ) id 1KbfVQ-0007ya-Pt for zsh-workers@sunsite.dk; Fri, 05 Sep 2008 19:54:00 +0200 Date: Fri, 05 Sep 2008 19:54:00 +0200 From: Frank Terbeck Subject: PATCH: _git: improve the way git aliases are fed into a hash To: zsh workers Mail-followup-to: zsh workers Message-id: <20080905175400.GD30607@fsst.voodoo.lan> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline X-IronPort-AV: E=Sophos;i="4.32,340,1217800800"; d="scan'208";a="82050400" User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: ClamAV 0.92.1/8167/Fri Sep 5 13:10:15 2008 on bifrost X-Virus-Status: Clean + 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 ) 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