From: Stephen Boyd Date: Fri, 13 Nov 2009 20:43:31 GMT Subject: Re: [PATCH] Speed up bash completion loading 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: > [...] > Suggested-by: Kirill Smelkov > Cc: Shawn O. Pearce > Cc: Stephen Boyd > Cc: Sverre Rabbelier > Cc: Junio C Hamano > Signed-off-by: Jonathan Nieder > --- 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 the first time when you're not in a git directory will make git merge -s 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 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 and then git help 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.*.*)