about summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Command/_git20
1 files changed, 13 insertions, 7 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index b1a509dd4..e062705ee 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -258,16 +258,22 @@ _git-branch () {
   d='-d -D'
 
   declare -a dependent_creation_args
-  dependent_creation_args=(
-    "($l $m $d): :__git_branch_names"
-    "::start-point:__git_revisions")
+  if (( words[(I)-r] == 0 )); then
+    dependent_creation_args=(
+      "($l $m $d): :__git_branch_names"
+      "::start-point:__git_revisions")
+  fi
 
   declare -a dependent_deletion_args
   if (( words[(I)-d] || words[(I)-D] )); then
     dependent_creation_args=
     dependent_deletion_args=(
-      '-r[delete remote-tracking branches]'
-      '*: :__git_ignore_line_inside_arguments __git_branch_names')
+      '-r[delete only remote-tracking branches]')
+    if (( words[(I)-r] )); then
+      dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_remote_branch_names'
+    else
+      dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_branch_names'
+    fi
   fi
 
   declare -a dependent_modification_args
@@ -281,7 +287,7 @@ _git-branch () {
   _arguments -w -S -s \
     "($c $m $d --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
     "($c $m $d : --color)--no-color[turn off branch coloring]" \
-    "($c $m $d : -a)-r[list only the remote-tracking branches]" \
+    "($c $m      -a)-r[list or delete only remote-tracking branches]" \
     "($c $m $d : -r)-a[list both remote-tracking branches and local branches]" \
     "($c $m $d : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
     "($c $m $d :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
@@ -4919,7 +4925,7 @@ __git_remote_branch_names () {
   local expl
   declare -a branch_names
 
-  branch_names=(${${(f)"$(_call_program remote-branch-refs git for-each-ref --format='%(refname)' refs/remotes 2>/dev/null)"}#refs/remotes/})
+  branch_names=(${${(f)"$(_call_program remote-branch-refs git for-each-ref --format='"%(refname)"' refs/remotes 2>/dev/null)"}#refs/remotes/})
   __git_command_successful $pipestatus || return
 
   _wanted remote-branch-names expl 'remote branch name' compadd $* - $branch_names