Re: [PATCH] Speed up bash completion loading
From: SZEDER Gábor <hidden>
Date: 2016-06-15 22:47:43
Hi, On Sat, Nov 14, 2009 at 05:01:41AM -0600, Jonathan Nieder wrote:
Stephen Boyd wrote:quoted
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.Not good. I think the sanest thing to do is avoid caching the merge strategy list entirely. Listing merge strategies takes about 100 ms here, which is short enough not to be annoying.quoted
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?Right, if this happened to me I would not be too surprised. A similar problem occurs when someone installs a new git subcommand in the middle of a session. Starting a new session fixes the completion, but should the completion script do something to help people before then? It could provide a shell function with a slightly friendlier name than "__git_compute_porcelain_commands" for the user to invoke explicitly. It could retry "git help -a" each time completion was needed if it gave no results last time (i.e. use "${__git_all_commands:=" instead of "${__git_all_commands="). This would help with the missing git problem (which seems unusual), but not the missing git-svn. Maybe it could detect signs of user frustration (repeated attempts to complete the same thing?) and add to the frustration by silently fixing the cache.
Why? Don't get overly creative here, the command . /path/to/git-completion.bash already does that, plus it fixes the merge strategy completion issue, and it's friendly enough for the users. Best, Gábor