mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-07-17 18:51:02 +02:00
31159: git: Pass prefix filter to ls-files even if it matches no files
When a branch or tag name is completed with zsh in a large git repo, the completion is slow if the given prefix doesn't match a file or directory in the current working directory. Testing with linux.git, which contains release tags like v3.9 and a directory virt/: git log v<tab> takes about 0.5 seconds, while git log v3<tab> takes about 25 seconds. (Timed using zsh 4.3.17, on a fairly slow cpu. zsh from git appears to be quite a bit faster, but the difference between completing v and v3 is still large.) The difference between the two is that v<tab> passes the result of v* to git ls-files while v3<tab> determines that v3* matches no files, and passes an empty prefix to git ls-files. So git ls-files lists all files in the repo and passes that on to _multi_parts. Making git do the expansion of the * after the prefix lets git ls-files v3* return an empty list, making _multi_parts job easier. This does not affect the behavior of git log <tab>, but improves the performance of partial tag and branch tab-completion in the common case where file names and tag/branch names don't overlap.
This commit is contained in:
parent
fa7c51971d
commit
cc7437bf2f
2 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2013-04-20 Torstein Hegge <hegge@resisty.net>
|
||||
|
||||
* 31159: Completion/Unix/Command/_git: git: Pass prefix filter to
|
||||
ls-files even if it matches no files
|
||||
|
||||
2013-04-20 Jun T <takimoto-j@kba.biglobe.ne.jp>
|
||||
|
||||
* 31281: Completion/Unix/Command/_du: _du: add support for Mac OS
|
||||
|
|
|
@ -5345,7 +5345,7 @@ __git_files () {
|
|||
# TODO: --directory should probably be added to $opts when --others is given.
|
||||
|
||||
local pref=$gitcdup$gitprefix$PREFIX
|
||||
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard $opts -- ${pref:+$pref\*} 2>/dev/null)"})
|
||||
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard $opts -- ${pref:+$pref\\\*} 2>/dev/null)"})
|
||||
__git_command_successful $pipestatus || return
|
||||
|
||||
# _wanted $tag expl $description _files -g '{'${(j:,:)files}'}' $compadd_opts -
|
||||
|
|
Loading…
Reference in a new issue