From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10414 invoked by alias); 20 Apr 2013 19:44:23 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31297 Received: (qmail 1602 invoked from network); 20 Apr 2013 19:44:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at pvv.ntnu.no does not designate permitted sender hosts) Date: Sat, 20 Apr 2013 21:00:56 +0200 From: Torstein Hegge To: zsh-workers@zsh.org Subject: Re: [PATCH] git: Pass prefix filter to ls-files even if it matches no files Message-ID: <20130420190056.GA5650@pvv.ntnu.no> References: <20130317123525.GB30500@pvv.ntnu.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20130317123525.GB30500@pvv.ntnu.no> User-Agent: Mutt/1.5.20 (2009-06-14) On Sun, Mar 17, 2013 at 13:35:25 +0100, Torstein Hegge wrote: > 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 > > takes about 0.5 seconds, while > > git log v3 > > 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 passes the result of v* to git > ls-files while v3 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 , 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. > --- No interest in this? Or did I miss something obvious? > Completion/Unix/Command/_git | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git > index 2b6a369..d736367 100644 > --- a/Completion/Unix/Command/_git > +++ b/Completion/Unix/Command/_git > @@ -5339,7 +5339,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 - > -- > 1.7.10.4 > >