From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13416 invoked by alias); 8 May 2015 13:50:29 -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: 35060 Received: (qmail 29606 invoked from network); 8 May 2015 13:50:22 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= x-mailer:message-id:date:date:subject:subject:from:from:received :received:received; s=postfix2; t=1431092471; bh=no8CHl25hwgEaaR CGLokI9JGeovq9n/rM9bzAOwkNlo=; b=R7evBnh01qSCQtw+qcVmNkQSJyNNrHc JZJPiM04dALPIOewtXcQby4z+XjzcvZEpTE76mp5PWc3vnvzFBk8JJIxALpllX30 8A9vmP1WqLLbT4HYnDfFuh8NWQmVPalruYtKlNevdB7EcvBmFFfL8U7Nm0UPFkZE zfdOr7RMgp3A= From: Daniel Hahler To: zsh-workers@zsh.org Subject: [PATCH] completion: git: split __git_heads into local and remote Date: Fri, 8 May 2015 15:41:01 +0200 Message-Id: <1431092461-24031-1-git-send-email-genml+zsh-workers@thequod.de> X-Mailer: git-send-email 2.4.0.dirty From: Daniel Hahler It is useful to have this distinction visually. This also uses `--format=%(refname:short)` directly with `git for-each-ref`. --- Completion/Unix/Command/_git | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 979e3e7..c01333b 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5614,10 +5614,16 @@ __git_commits () { (( $+functions[__git_heads] )) || __git_heads () { + __git_heads_local + __git_heads_remote +} + +(( $+functions[__git_heads_local] )) || +__git_heads_local () { local gitdir expl start declare -a heads - heads=(${${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname)"' refs/heads refs/remotes 2>/dev/null)"}#refs/(heads|remotes)/}) + heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)" refs/heads' 2>/dev/null)"}) gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) if __git_command_successful $pipestatus; then for f in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do @@ -5626,7 +5632,17 @@ __git_heads () { [[ -f $gitdir/refs/stash ]] && heads+=stash fi - _wanted heads expl head compadd "$@" -a - heads + _wanted heads-local expl "local head" compadd "$@" -a - heads +} + +(( $+functions[__git_heads_remote] )) || +__git_heads_remote () { + local gitdir expl start + declare -a heads + + heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)" refs/remotes' 2>/dev/null)"}) + + _wanted heads-remote expl "remote head" compadd "$@" -a - heads } (( $+functions[__git_commit_objects] )) || -- 2.4.0.dirty