From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14547 invoked from network); 29 Sep 2007 06:02:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) 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.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 29 Sep 2007 06:02:51 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 31306 invoked from network); 29 Sep 2007 06:02:43 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Sep 2007 06:02:43 -0000 Received: (qmail 22031 invoked by alias); 29 Sep 2007 06:02:39 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23851 Received: (qmail 22012 invoked from network); 29 Sep 2007 06:02:39 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 29 Sep 2007 06:02:39 -0000 Received: (qmail 30913 invoked from network); 29 Sep 2007 06:02:39 -0000 Received: from acolyte.scowler.net (216.254.112.45) by a.mx.sunsite.dk with SMTP; 29 Sep 2007 06:02:33 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id 9FC0B5C2CC; Sat, 29 Sep 2007 02:02:31 -0400 (EDT) Date: Sat, 29 Sep 2007 02:02:31 -0400 From: Clint Adams To: zsh-workers@sunsite.dk Cc: madcoder@debian.org Subject: PATCH: _git, Use ad-hoc functions to list branches/tags Message-ID: <20070929060231.GA790@scowler.net> Mail-Followup-To: zsh-workers@sunsite.dk, madcoder@debian.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.16 (2007-06-11) Patch from Pierre Habouzit to allow completion for origin/* branches. Index: Completion/Unix/Command/_git =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v retrieving revision 1.29 diff -u -r1.29 _git --- Completion/Unix/Command/_git 27 Sep 2007 12:40:27 -0000 1.29 +++ Completion/Unix/Command/_git 29 Sep 2007 06:00:36 -0000 @@ -2846,30 +2846,26 @@ __git_tag_ids () { } -(( $+functions[__git_heads_or_tags] )) || -__git_heads_or_tags () { +(( $+functions[__git_heads] )) || +__git_heads () { local expl - declare -a refs opts - declare -A ours - - zparseopts -K -D -a opts S: M: J: V: 1 2 n F: X: P:=ours T:=ours - - (( $+ours[-P] )) || ours[-P]=./. + declare -a branch_names - refs=(${${${${(f)"$(_call_program $ours[-T] git ls-remote --$ours[-T] $ours[-P] 2>/dev/null)"}#*$'\t'}:#*\^*}#refs/$ours[-T]/}) + branch_names=(${${(f)"$(_call_program heads git branch -a 2>/dev/null)"}#[* ] }) __git_command_successful || return - _wanted $ours[-T] expl $ours[-T] compadd $opts - $refs -} - -(( $+functions[__git_heads] )) || -__git_heads () { - __git_heads_or_tags $* -T heads && ret=0 + _wanted heads expl branch-name compadd $* - $branch_names } (( $+functions[__git_tags] )) || __git_tags () { - __git_heads_or_tags $* -T tags && ret=0 + local expl + declare -a tag_names + + tag_names=(${${(f)"$(_call_program tags git tag -l 2>/dev/null)"}#[* ] }) + __git_command_successful || return + + _wanted tags expl tag-name compadd $* - $tag_names } # TODO: depending on what options are on the command-line already, complete