about summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
authordana <dana@dana.is>2021-04-10 15:54:26 -0500
committerdana <dana@dana.is>2021-04-10 15:54:26 -0500
commit7269bc1ac46852f8624b99211500276c758eb46e (patch)
tree7b6d02f05dabbade99f7487ca591b8cc45286354 /Completion/Unix
parent283d2f3c2761ac549a647638bb7d8fd8de3dabb4 (diff)
downloadzsh-7269bc1ac46852f8624b99211500276c758eb46e.tar.gz
zsh-7269bc1ac46852f8624b99211500276c758eb46e.tar.xz
zsh-7269bc1ac46852f8624b99211500276c758eb46e.zip
48338: _git: Support case-insensitive path matching
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Command/_git11
1 files changed, 8 insertions, 3 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index ced89b501..0267acfa8 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -7155,11 +7155,16 @@ __git_files () {
   local pref=${(Q)${~PREFIX}}
   [[ $pref[1] == '/' ]] || pref=$gittoplevel$gitprefix$pref
 
-  # First allow ls-files to pattern-match in case of remote repository
-  files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\*}:-.} 2>/dev/null)"})
+  # 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\)$pref\*}:-.} 2>/dev/null)"})
   __git_command_successful $pipestatus || return
 
-  # If ls-files succeeded but returned nothing, try again with no pattern
+  # If ls-files succeeded but returned nothing, try again with no pattern. Note
+  # that ls-files defaults to the CWD if not given a path, so if the file we
+  # were trying to add is in an *adjacent* directory, this won't return anything
+  # helpful either
   if [[ -z "$files" && -n "$pref" ]]; then
     files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- 2>/dev/null)"})
     __git_command_successful $pipestatus || return