zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] _git: Fix completion of diffs against the index when treeish isn't shell-safe
Date: Thu, 10 Mar 2016 23:15:51 +0000	[thread overview]
Message-ID: <1457651751-5176-1-git-send-email-danielsh@tarsus.local2> (raw)
In-Reply-To: <20160309233318.GA27898@tarsus.local2>

This affects 'git diff --cached -- <TAB>' and 'git reset $treeish <TAB>'.
---
To be applied on top of the last patch.

 Completion/Unix/Command/_git | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index f0ad3d9..6c88ad0 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -6077,7 +6077,8 @@ __git_diff-index_files () {
   local tree=$1 description=$2 tag=$3; shift 3
   local files expl
 
-  files=$(_call_program files git diff-index -z --name-only --no-color --cached $tree 2>/dev/null)
+  # $tree needs to be escaped for _call_program; matters for $tree = "HEAD^"
+  files=$(_call_program files git diff-index -z --name-only --no-color --cached ${(q)tree} 2>/dev/null)
   __git_command_successful $pipestatus || return 1
   files=(${(0)"$(__git_files_relative $files)"})
   __git_command_successful $pipestatus || return 1


  reply	other threads:[~2016-03-10 23:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26  8:08 _git-reset doesn't complete newly staged files Jun T.
2016-03-03  5:07 ` Jun T.
2016-03-07  3:16   ` Jun T.
2016-03-09 13:24   ` Daniel Shahaf
2016-03-09 23:33     ` Daniel Shahaf
2016-03-10 23:15       ` Daniel Shahaf [this message]
2016-03-10 12:03     ` Jun T.
2016-03-10 14:35       ` Mikael Magnusson
2016-03-10 23:20       ` __git_ignore_line positional argument (un)escaping (was: Re: _git-reset doesn't complete newly staged files) Daniel Shahaf
2016-03-11  8:24         ` Jun T.
2016-03-11 22:13           ` Daniel Shahaf

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=1457651751-5176-1-git-send-email-danielsh@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --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).