Re: Bash completion very slow in large repo
Matthew Hughes <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <aoYQ9CCzPM3qKVfZ@desktop> |
On Fri, Aug 14, 2026 at 07:55:36PM +0100, Matthew Hughes wrote:
> I'm not sure about potential fixes. Hacking around on it the best I could come
> up with was a workaround: add an env var to skip index completion during bash
> completion, so the completion falls back to the default Bash file completion
> (i.e. complete any time), here that is (just for demonstration):
My final workaround (read: filthy hack) was to re-define
`__git_complete_index_file` just after sourcing the completion script like:
# copy __git_complete_index_file to __orig__git_complete_index_file
eval "__orig$(declare -f __git_complete_index_file)"
__git_complete_index_file () {
# options that require 'git' to inspect all files on disk
local slow_opts_re="(^|[[:space:]])(--others|--modified|--deleted|--ignored|--killed)($|[[:space:]])"
if [[ "$1" =~ $slow_opts_re ]]
then
return
fi
__orig__git_complete_index_file "$@"
}