zsh-workers
 help / color / mirror / code / Atom feed
From: "Jörg Sommer" <joerg@alea.gnuu.de>
To: zsh-workers@sunsite.dk
Subject: Re: [PATCH] Re: git completion is really slow for some git commands.
Date: Mon, 13 Oct 2008 17:01:20 +0200	[thread overview]
Message-ID: <20081013150120.GA16647@alea.gnuu.de> (raw)
In-Reply-To: <1223885753.29462.7.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 2312 bytes --]

Hello Brice,

Brice Figureau schrieb am Mon 13. Oct, 10:15 (+0200):
> On Mon, 2008-10-13 at 00:53 +0000, Jörg Sommer wrote:
> > >  * this shell array is then passed to _multi_parts for path splitting of
> > > each element. This is this operation that takes age. As soon as I change
> > > the _multi_parts code to just call a naive compadd and return, the
> > > completion is (almost) immediate, and seems to work fine.
> > 
> > Can you try this patch? It doesn't change anything if you didn't specify
> > anything, i.e. git log -- <TAB> takes still very long. But it optimizes
> > the case when you specify anything. Try git log -- some/thing<TAB>.
> 
> [snipped patch]
> 
> Yes, that works way faster for this case. Unfortunately it doesn't seem
> to report the right results:

I've forgot to put the result back in an array. Try this patch:

commit e8536069c36e8ae310e249356274a398bf5bd38d
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date:   Mon Oct 13 01:58:03 2008 +0200

    Prefilter the completion for _multi_parts
    
    The _multi_parts function consumes very much time, if the array with the
    possible completions is large. This happens often in large git
    repositories like the kernel git repository. To reduce the workload of
    _multi_parts filter out does entries from the array, they aren't possible
    completions. When the user specifies the path foo/bar only consider paths
    matching the pattern foo*/bar*.

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index c617613..b6f5297 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -2761,6 +2761,7 @@ __git_files () {
   files=(${(ps:\0:)"$(_call_program files git ls-files -z $ls_opts $opts 2>/dev/null)"})
   __git_command_successful || return
 
+  [[ -n $PREFIX ]] && files=(${(M)files:#${~PREFIX//\//*/}*})
   _wanted files expl 'index file' _multi_parts $@ - / files
 }
 
@@ -2859,6 +2860,7 @@ __git_tree_files () {
   fi
 
   local expl
+  [[ -n $PREFIX ]] && tree_files=(${(M)tree_files:#${~PREFIX//\//*/}*})
   _wanted files expl 'tree file' _multi_parts -f $@ -- / tree_files
 }
 

Bye, Jörg.
-- 
Objektivität ist die Wahnvorstellung, Beobachtungen könnten ohne
Beobachter gemacht werden – Heinz v. Foerster

[-- Attachment #2: Digital signature http://en.wikipedia.org/wiki/OpenPGP --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2008-10-13 15:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09 13:01 Brice Figureau
2008-10-13  0:53 ` [PATCH] " Jörg Sommer
2008-10-13  8:15   ` Brice Figureau
2008-10-13 15:01     ` Jörg Sommer [this message]
2008-10-13 15:45       ` Brice Figureau

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=20081013150120.GA16647@alea.gnuu.de \
    --to=joerg@alea.gnuu.de \
    --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).