From: "Mikael Magnusson" <mikachu@gmail.com>
To: zsh-workers@sunsite.dk
Subject: Re: git completion horribly slow in kernel tree
Date: Mon, 14 Jan 2008 22:39:58 +0100 [thread overview]
Message-ID: <237967ef0801141339p73414915xc411253211ed7467@mail.gmail.com> (raw)
In-Reply-To: <slrnfongql.jes.joerg@alea.gnuu.de>
On 14/01/2008, Jörg Sommer <joerg@alea.gnuu.de> wrote:
> Hi,
>
> using completion for git in the kernel tree is horribly slow. It takes
> more than ten seconds to get the answer that no completion for "git log
> o" is available. The reason might be that git ls-files gives 23,000 file
> names and zsh puts them in an array. It there any chance to speed this
> up?
I tried to fix that once but I gave up because I don't use any git
trees that large usually. basically the problem is _git calls
git-ls-tree with -r, which means recursive. I have this patch lying
around but it isn't finished. I don't remember what isn't finished
either but maybe it helps someone anyway?
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 5f71848..0f3db0e 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -826,12 +826,12 @@ _git-diff-tree () {
# new tree:
# ...
_alternative \
- "original tree:original tree:__git_tree_files $line[1]" \
- "new tree:new tree:__git_tree_files $line[2]" && ret=0
+ "original tree:original tree:__git_tree_files . $line[1]" \
+ "new tree:new tree:__git_tree_files . $line[2]" && ret=0
else
_alternative \
': :__git_tree_ishs' \
- ": :__git_tree_files $line[1]" && ret=0
+ ": :__git_tree_files . $line[1]" && ret=0
fi
;;
esac
@@ -924,7 +924,7 @@ _git-ls-tree () {
case $state in
files)
- __git_tree_files $line[1] && ret=0
+ __git_tree_files . $line[1] && ret=0
;;
esac
}
@@ -1366,7 +1366,7 @@ _git-archive () {
case $state in
(files)
- __git_tree_files $line[1] && ret=0
+ __git_tree_files . $line[1] && ret=0
;;
esac
}
@@ -1504,7 +1504,7 @@ _git-checkout () {
case $state in
(files)
if [[ -n $line[1] ]]; then
- __git_tree_files $line[1] && ret=0
+ __git_tree_files . $line[1] && ret=0
else
__git_cached_files && ret=0
fi
@@ -1690,13 +1690,13 @@ _git-grep () {
else
_alternative \
'tree:tree:__git_trees' \
- "tree file:tree-files:__git_tree_files
$line[first_tree,last_tree]" && ret=0
+ "tree file:tree-files:__git_tree_files .
$line[first_tree,last_tree]" && ret=0
fi
else
if (( first_tree == 0 )); then
__git_cached_files
else
- __git_tree_files $line[first_tree,last_tree]
+ __git_tree_files . $line[first_tree,last_tree]
fi
fi
;;
@@ -1836,7 +1836,7 @@ _git-reset () {
if [[ $words[2] == --mixed ]]; then
commit_arg=':commit:__git_revisions'
- path_arg="*:file:__git_tree_files $words[3]"
+ path_arg="*:file:__git_tree_files . $words[3]"
else
commit_arg='::commit:__git_revisions'
fi
@@ -2559,7 +2559,7 @@ __git_command_successful () {
__git_objects () {
compset -P '*:'
if [[ -n $IPREFIX ]]; then
- __git_tree_files ${IPREFIX%:}
+ __git_tree_files "$PREFIX" "${IPREFIX%:}"
else
_alternative \
'revisions:revision:__git_revisions' \
@@ -2652,13 +2652,16 @@ __git_tree_files () {
zparseopts -D -E -a multi_parts_opts M: J: V: 1 2 n F: X:
- local tree
+ local tree Path
integer at_least_one_tree_added
local -a tree_files
+ Path=${1%/*}/
+ [[ $Path = / ]] && Path=.
+ shift
(( at_least_one_tree_added = 0 ))
for tree in $*; do
- tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree
--name-only -z -r $tree 2>/dev/null)"})
+ tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree
--name-only -z $tree $Path 2>/dev/null)"})
__git_command_successful && (( at_least_one_tree_added = 1 ))
done
--
Mikael Magnusson
next prev parent reply other threads:[~2008-01-14 21:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-14 20:17 Jörg Sommer
2008-01-14 21:39 ` Mikael Magnusson [this message]
2008-01-22 1:19 ` Clint Adams
2008-01-22 1:40 ` Mikael Magnusson
2008-01-22 16:22 ` Clint Adams
2008-01-22 17:04 ` Clint Adams
2008-01-22 21:04 ` Nikolai Weibull
2008-01-22 21:16 ` Mikael Magnusson
2008-01-22 17:12 ` Clint Adams
2008-01-23 11:20 ` Mikael Magnusson
2008-01-23 13:29 ` Clint Adams
2008-01-23 16:30 ` Mikael Magnusson
2008-01-23 16:48 ` Clint Adams
2008-01-23 17:03 ` Mikael Magnusson
2008-01-24 6:46 ` Mikael Magnusson
2008-01-24 7:20 ` Mikael Magnusson
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=237967ef0801141339p73414915xc411253211ed7467@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@sunsite.dk \
/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).