Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] __git_recent_branches: Silence warning on an edge case.
- X-seq: zsh-workers 39122
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] __git_recent_branches: Silence warning on an edge case.
- Date: Tue, 30 Aug 2016 03:36:48 +0000
- Cc: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=	daniel.shahaf.name; h=cc:date:from:in-reply-to:message-id	:references:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=blmG1	iYdsk9w6OUW3zLuo6wpVmc=; b=eRwtBLTOmQQ3fdYlbhrNfLW5Mgq823BhOg2H1	wQm5Jxd+TFOTk6bva2sKlqyuh1aWRYV7qtp+ZYBFE3cAug1r/nNIgxwHFsClhGV8	/GbT4nMg+elD2btJTg0tvWkG/LmoFcQ2LOuuP+TEI/HtzsxZMcZxqbT1vhbM+Qar	MqqoBI=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=	messagingengine.com; h=cc:date:from:in-reply-to:message-id	:references:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=blmG	1iYdsk9w6OUW3zLuo6wpVmc=; b=hR8w+F5hM8gV3XtVStGpe1XBfDV54A3u/DKd	0ZDq6wQ5OJAm7e6sPETrXc9VeVT+JyZujeTI+bsK66IiV73vXz5WR3SBD9obUKsH	UgrGyFhRG3w2KXJ/X66C3uXuzOz3l73jMQdQ9S507e+5Vs85xXJ9PeA4nSXJ8yIs	w6BDD4Q=
- In-reply-to: <1472086748-16738-1-git-send-email-danielsh@fujitsu.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1472086748-16738-1-git-send-email-danielsh@fujitsu.shahaf.local2>
(The warning was correct; there is no functional change, though.)
---
 Completion/Unix/Command/_git | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index afa3bcb..8d3bd63 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author