Re: [PATCH] Speed up bash completion loading
- From
Stephen Boyd <bebarino@gmail.com>
- Date
- Nov 13, 2009, 20:43 UTC
- Message-ID
- <4AFDC4F3.1050607@gmail.com>
- In-Reply-To
- <20091113090343.GA5355@progeny.tock>
Jonathan Nieder wrote:
> On my slow laptop (P3 600MHz), system-wide bash completions take > too much time to load (> 2s), and a significant fraction of this > time is spent loading git-completion.bash: >
[...]
Show 7 quoted lines
> Suggested-by: Kirill Smelkov <kirr@mns.spb.ru> > Cc: Shawn O. Pearce <spearce@spearce.org> > Cc: Stephen Boyd <bebarino@gmail.com> > Cc: Sverre Rabbelier <srabbelier@gmail.com> > Cc: Junio C Hamano <junio@pobox.com> > Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> > ---
I was under the impression that setting variables during completion meant they were lost at the end of the completion cycle. So to be safe I put a 'sleep 5' in __git_list_porcelain_commands() and it only stalled me once :-)
I see a small problem, but it can be fixed in another patch. git merge -s <TAB><TAB> the first time when you're not in a git directory will make git merge -s <TAB><TAB> after never complete correctly even in a git directory. I guess this become more serious if git isn't in your path initially and you do git <TAB><TAB> and then git becomes part of your path and you try again. Here you lose porcelain completion. This is probably never going to happen though, right?
Plus it seems that __git_all_commands is computed twice if I git <TAB><TAB> and then git help <TAB><TAB> after. Can that be avoided?
Squashing this on top fixes the two typos you mentioned.
---->8----
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 7088ec7..6817953 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1082,7 +1082,7 @@ _git_help () ;; esac __git_compute_all_commands - __gitcomp "__git_all_commands + __gitcomp "$__git_all_commands attributes cli core-tutorial cvs-migration diffcore gitk glossary hooks ignore modules repository-layout tutorial tutorial-2 @@ -1541,7 +1541,7 @@ _git_config () local pfx="${cur%.*}." cur="${cur#*.}" __git_compute_all_commands - __gitcomp "__git_all_commands" "$pfx" "$cur" + __gitcomp "$__git_all_commands" "$pfx" "$cur" return ;; remote.*.*)