From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17562 invoked by alias); 21 Mar 2010 19:54:58 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27814 Received: (qmail 22349 invoked from network); 21 Mar 2010 19:54:56 -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-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Sun, 21 Mar 2010 15:48:06 -0400 (EDT) From: "Benjamin R. Haskell" To: Zsh Workers Subject: Re: [PATCH] _git: Also complete FETCH_HEAD, ORIG_HEAD and MERGE_HEAD. In-Reply-To: <20100321172336.GA4151@ruderich.org> Message-ID: References: <20100321172336.GA4151@ruderich.org> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 21 Mar 2010, Simon Ruderich wrote: > Hi, > > Maybe it should be checked if FETCH_HEAD, ORIG_HEAD and > MERGE_HEAD exist before completing them, but I'm not sure how to > that. > > Simon This version checks that rev-parse returns something valid for each of those three 'symbolic ref names' (as git-rev-parse(1) calls them), plus 'HEAD' itself (which isn't a valid name on a newly-init'ed repository). It could probably be improved via the use of _call_program rather than calling 'git rev-parse' directly (the same way branch_names uses 'headrefs' to allow for zstyle niceness, I think), but I don't fully grok that yet. Best, Ben --- Completion/Unix/Command/_git | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index d7570cc..730a952 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -3119,13 +3119,18 @@ __git_tag_ids () { (( $+functions[__git_heads] )) || __git_heads () { - local expl + local expl head symbolic_heads declare -a branch_names branch_names=(${${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname)"' refs/heads refs/remotes 2>/dev/null)"}#refs/(heads|remotes)/}) __git_command_successful || return - _wanted heads expl branch-name compadd $* - $branch_names HEAD + symbolic_heads=() + for head in HEAD ORIG_HEAD FETCH_HEAD MERGE_HEAD ; do + git rev-parse $head &>/dev/null && symbolic_heads+=( $head ) + done + + _wanted heads expl branch-name compadd $* - $branch_names $symbolic_heads } (( $+functions[__git_tags] )) || -- 1.7.0