Re: [PATCH] Speed up bash completion loading
From: Stephen Boyd <hidden>
Date: 2016-06-15 22:47:43
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted> Cc: Shawn O. Pearce <redacted> Cc: Stephen Boyd <redacted> Cc: Sverre Rabbelier <redacted> Cc: Junio C Hamano <redacted> Signed-off-by: Jonathan Nieder <redacted> ---
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.*.*)