zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Hahler <genml+zsh-workers@thequod.de>
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	[thread overview]
Message-ID: <1431092461-24031-1-git-send-email-genml+zsh-workers@thequod.de> (raw)

From: Daniel Hahler <git@thequod.de>

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


             reply	other threads:[~2015-05-08 13:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 13:41 Daniel Hahler [this message]
2015-05-10 16:13 ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431092461-24031-1-git-send-email-genml+zsh-workers@thequod.de \
    --to=genml+zsh-workers@thequod.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).