Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: _git: __git_files double-quotes ls-files pathspec



Since 52904, __git_files quotes the ls-files pathspec twice: (qq) inside
(q), with a single eval in _call_program. git receives a literal
:(icase)'/repo/sub/../'* and matches nothing, so the CWD-only fallback
always runs. Visible when completing outside CWD.

Repro (zsh -f; autoload compinit; compinit):

  git init r && cd r && touch a && mkdir sub && cd sub
  git add ../<TAB>     # nothing; expected ../a

Patch below uses _call_program -q (2026/msg00759) and quotes the
pattern so it isn't globbed. Tested with spaces, quotes and non-ASCII
in paths.
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 43d2e87..6f9eb35 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -7994,7 +7994,7 @@ __git_files () {
   # First allow ls-files to pattern-match in case of remote repository. Use the
   # icase pathspec magic word to ensure that we support case-insensitive path
   # completion for users with the appropriate matcher configuration
-  files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+:\(icase\)${(qq)pref}\*}:-.} 2>/dev/null)"})
+  files=(${(0)"$(_call_program -q files git ls-files -z --exclude-standard $opts -- "${${pref:+:(icase)$pref*}:-.}" 2>/dev/null)"})
   __git_command_successful $pipestatus || return
 
   # If ls-files succeeded but returned nothing, try again with no pattern. Note


Messages sorted by: Reverse Date, Date, Thread, Author