From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Cc: Daniel Hahler <genml+zsh-workers@thequod.de>
Subject: [PATCH] __git_recent_branches: Silence warning on an edge case.
Date: Tue, 30 Aug 2016 03:36:48 +0000 [thread overview]
Message-ID: <1472528208-20150-1-git-send-email-danielsh@fujitsu.shahaf.local2> (raw)
In-Reply-To: <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
prev parent reply other threads:[~2016-08-30 3:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-25 0:59 [PATCH] __git_recent_branches: Optimise Daniel Shahaf
2016-08-30 3:36 ` Daniel Shahaf [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1472528208-20150-1-git-send-email-danielsh@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=genml+zsh-workers@thequod.de \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).