about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--Completion/Unix/Command/_git20
2 files changed, 19 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index eeab2835c..4052a8234 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-29  Nikolai Weibull <now@bitwi.se>
+
+	* unposted: Completion/Unix/Command/_git: Update git-branch completion
+	to deal with -r and -d correctly.
+
 2011-05-27  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 29403: Src/hist.c: histlexwords splitting of ";;" in case.
@@ -14874,5 +14879,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5344 $
+* $Revision: 1.5345 $
 *****************************************************
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