Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] completion: git: fix __git_commit_objects/__git_recent_commits
- X-seq: zsh-workers 35164
 
- From: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
 
- To: zsh-workers@xxxxxxx
 
- Subject: [PATCH] completion: git: fix __git_commit_objects/__git_recent_commits
 
- Date: Sun, 17 May 2015 19:37:53 +0200
 
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h=	x-mailer:message-id:date:date:subject:subject:from:from:received	:received:received; s=postfix2; t=1431884281; bh=sGwbBolyL3VRdKt	+PBQL6nr9rqUN37Xlc7Pv7SC+bfE=; b=suJj2+iRi4XRze/Nkt1UBsnLAr9Ugkn	hNNMcwYOs5ew/Av1tHDALfl9sWfg9wNyxnRfjKckikLxzc+ti7AT0I2qKAHj7w7O	1FjsRbK47+Mbr87mxtuU3/8arqIdPLQMK13c4PvIo1gfbWPxPwXmIMMeXOEouItv	1TyCXOFTcPvE=
 
- 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
 
From: Daniel Hahler <git@xxxxxxxxxx>
$pipestatus for `: foo` appears to be 0 always.
Explicitly declare `$commits` as associative array, and assign it
normally.
Without this, "git checkout" in a non-git directory would complete " ",
but not result in a note/error about not being in a git dir.
---
 Completion/Unix/Command/_git | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index ed23b39..da852ef 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -5649,11 +5649,11 @@ __git_heads_remote () {
 (( $+functions[__git_commit_objects] )) ||
 __git_commit_objects () {
   local gitdir expl start
-  declare -a commits
+  declare -A commits
 
   # Note: the after-the-colon part must be unique across the entire array;
   # see workers/34768
-  : ${(A)commits::=${(f)"$(_call_program commits git --no-pager log -20 --format='%h:\\\[%h\\\]\ %s')"}}
+  commits=(${(f)"$(_call_program commits git --no-pager log -20 --format='%h:\\\[%h\\\]\ %s')"})
   __git_command_successful $pipestatus || return 1
 
   _describe -V -t commits 'commit object name' commits || _guard '[[:xdigit:]](#c,40)' 'commit object name'
@@ -5662,11 +5662,12 @@ __git_commit_objects () {
 (( $+functions[__git_recent_commits] )) ||
 __git_recent_commits () {
   local gitdir expl start
-  declare -a descr tags heads commits
+  declare -a descr tags heads
+  declare -A commits
   local i j k
 
   # Careful: most %d will expand to the empty string.  Quote properly!
-  : "${(A)commits::=${(@f)"$(_call_program commits git --no-pager log -20 --format='%h%n%d%n%s')"}}"
+  commits=(${(@f)"$(_call_program commits git --no-pager log -20 --format='%h%n%d%n%s')"})
   __git_command_successful $pipestatus || return 1
 
   for i j k in "$commits[@]" ; do
-- 
2.4.0.dirty
Messages sorted by:
Reverse Date,
Date,
Thread,
Author