Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Git completion slowness



"Benjamin R. Haskell" wrote:
> That prevents all git file completion, which is the cause of the 
> slowness (specifically, _multi_parts completion for filenames).  Recall 

It's never a great idea when some function tries to do it's own filename
completion. While perhaps not blazingly fast, I very much think that the
approach I took in _subversion is the best. That approach is to use
_files for the actual completion and use the e glob qualifier to filter
the files. That way, the many configuration styles and everything for
filename completion works as normal. I notice that _git is completing
dot files for me without an initial dot for instance.

So for _git-add, we'd need something like:
__git_filestatus() {
  [[ $(git status --porcelain $REPLY) = ?M* ]]
}

__git_modified_files () {
  _files -g "*(.e:__git_filestatus:)"
}

That may need to run git status for every file but that's way better
than recursing through every subdirectory. Note that it is possible to
add non-existant files - look at _subversion for an example.

This also loses you the division of files into ignored-modified-files,
ignored-other-files etc but you can actually put that back in with a
suitable file-patterns style provided __git_filestatus doesn't hard code
the regex/pattern (and options needed for e.g. ignored files).

I would work on this but if Nikolai has a rewritten _git, I'll hold off.

By the way, what's with all the double underscores in _git. Is there
some meaning to those or has someone just been doing too much Python.

Oliver



Messages sorted by: Reverse Date, Date, Thread, Author