summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_git11
2 files changed, 14 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4d2de8d86..866e2add1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-31  Daniel Shahaf  <d.s@daniel.shahaf.name>
+
+	* 39122: Completion/Unix/Command/_git: __git_recent_branches:
+	Silence warning on an edge case.
+
 2016-08-30  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
 	* 39108: Completion/Unix/Command/_postfix: Support
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index afa3bcb4a..8d3bd6307 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -6070,7 +6070,14 @@ __git_recent_branches() {
   #    (We must do this because #3 would otherwise croak on them.)
   __git_recent_branches__names; branches=( ${(@)reply:*valid_ref_names_munged} )
 
-  # 3. Obtain log messages for all of them in one shot.
+  # 3. Early out if no matches.
+  if ! (( $+branches[1] )); then
+    # This can happen in a fresh repository (immediately after 'clone' or 'init') before
+    # any 'checkout' commands were run in it.
+    return 1
+  fi
+
+  # 4. Obtain log messages for all of them in one shot.
   descriptions=( ${(f)"$(_call_program all-descriptions git --no-pager log --no-walk=unsorted --pretty=%s ${(q)branches} --)"} )
 
   if (( $#branches != $#descriptions )); then
@@ -6079,7 +6086,7 @@ __git_recent_branches() {
     return 1
   fi
 
-  # 4. Synthesize the data structure _describe wants.
+  # 5. Synthesize the data structure _describe wants.
   local -a branches_colon_descriptions
   local branch description
   for branch description in ${branches:^descriptions} ; do