mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 03:32:44 +08:00
completions/git: Stop limiting to the token
This enables fuzzy-matching outside of the current directory again. As it turns out, the performance impact here isn't as large as I thought - it's massively dependent on caching. Fixes #5476.
This commit is contained in:
parent
de145477be
commit
73bae383e0
|
@ -144,19 +144,13 @@ function __fish_git_files
|
|||
# (don't use --ignored=no because that was only added in git 2.16, from Jan 2018.
|
||||
set -q ignored; and set -a status_opt --ignored
|
||||
|
||||
# Glob just the current token for performance
|
||||
# and so git shows untracked files (even in untracked dirs) for that.
|
||||
# If the current token is empty, this matches everything in $PWD.
|
||||
set -l files (commandline -ct)
|
||||
# The trailing "**" is necessary to match files inside the given directories.
|
||||
set files "$files*" "$files*/**"
|
||||
set -q untracked; and set -a status_opt -unormal
|
||||
or set -a status_opt -uno
|
||||
|
||||
# We need to set status.relativePaths to true because the porcelain v2 format still honors that,
|
||||
# and core.quotePath to false so characters > 0x80 (i.e. non-ASCII) aren't considered special.
|
||||
# We explicitly enable globs so we can use that to match the current token.
|
||||
set -l git_opt -c status.relativePaths -c core.quotePath= --glob-pathspecs
|
||||
set -l git_opt -c status.relativePaths -c core.quotePath=
|
||||
|
||||
# We pick the v2 format if we can, because it shows relative filenames (if used without "-z").
|
||||
# We fall back on the v1 format by reading git's _version_, because trying v2 first is too slow.
|
||||
|
@ -278,7 +272,7 @@ function __fish_git_files
|
|||
set -l previousfile
|
||||
# Note that we can't use space as a delimiter between status and filename, because
|
||||
# the status can contain spaces - " M" is different from "M ".
|
||||
command git $git_opt status --porcelain -z $status_opt -- $files \
|
||||
command git $git_opt status --porcelain -z $status_opt \
|
||||
| while read -lz line
|
||||
set -l desc
|
||||
# The entire line is the "from" from a rename.
|
||||
|
|
Loading…
Reference in New Issue
Block a user