about summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2015-05-08 15:41:01 +0200
committerDaniel Shahaf <d.s@daniel.shahaf.name>2015-05-12 00:59:07 +0000
commitb884853756f0bd3489f2bad9e464498c798c672c (patch)
tree2b53bd6b39d1abd9b5dd84f26236709e0ae19e1f /Completion/Unix
parentffdeb1c25728c722567d6f9de2d714f3f1f2a4de (diff)
downloadzsh-b884853756f0bd3489f2bad9e464498c798c672c.tar.gz
zsh-b884853756f0bd3489f2bad9e464498c798c672c.tar.xz
zsh-b884853756f0bd3489f2bad9e464498c798c672c.zip
35060 + 35072: completion: git: split __git_heads into local and remote
It is useful to have this distinction visually.

This also uses `--format=%(refname:short)` directly with `git
for-each-ref`.
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Command/_git20
1 files changed, 18 insertions, 2 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 979e3e76f..c01333ba4 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] )) ||