Re: [PATCH] Speed up bash completion loading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <kirr@xxxxxxxxxx>
Cc: Shawn O. Pearce <spearce@xxxxxxxxxxx>
Cc: Stephen Boyd <bebarino@xxxxxxxxx>
Cc: Sverre Rabbelier <srabbelier@xxxxxxxxx>
Cc: Junio C Hamano <junio@xxxxxxxxx>
Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---

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.*.*)


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]