From: Stephen Boyd <hidden> Date: 2016-06-15 22:47:36
I should have looked at the actual generated completion before hastily
sending my last fix. Looks like we get the merge strategies twice in the
merge strategy list.
The second patch is a quick hack to have completion lazily load again
while still allowing pre-generated completion.
These are on top of next.
Stephen Boyd (2):
completion: ignore custom merge strategies when pre-generating
completion: allow use without compiling
contrib/completion/git-completion.bash.generate | 1 +
contrib/completion/git-completion.bash.in | 132 +++++++++++++++++++++--
2 files changed, 124 insertions(+), 9 deletions(-)
From: Stephen Boyd <hidden> Date: 2016-06-15 22:47:36
Since the Makefile adds the build directory to PATH, we get the merge
strategies twice. Ignore custom merge strategies which are just the
builtin merge strategies (octopus.sh, ours.sh, etc.) anyway.
Signed-off-by: Stephen Boyd <redacted>
---
contrib/completion/git-completion.bash.generate | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
From: Stephen Boyd <hidden> Date: 2016-06-15 22:47:36
Some users don't want to compile their completion, even when the build
generated completion is 10x faster to load. For example, in my bashrc I
source the completion script directly so I can stay up to date with the
latest completion by merely pulling changes.
Do this by generating the lists dynamically when the merge strategy and
command lists still have their initial values (__GIT_MERGE_STRATEGYLIST,
__GIT_ALL_COMMANDLIST).
Signed-off-by: Stephen Boyd <redacted>
---
This duplicates code, but I don't know of a way to re-use the dynamic
code without sourcing a bash script and possibly breaking someone's build.
contrib/completion/git-completion.bash.in | 132 +++++++++++++++++++++++++++--
1 files changed, 123 insertions(+), 9 deletions(-)
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:37
Stephen Boyd [off-list ref] writes:
Some users don't want to compile their completion, even when the build
generated completion is 10x faster to load. For example, in my bashrc I
source the completion script directly so I can stay up to date with the
latest completion by merely pulling changes.
Do this by generating the lists dynamically when the merge strategy and
command lists still have their initial values (__GIT_MERGE_STRATEGYLIST,
__GIT_ALL_COMMANDLIST).
Signed-off-by: Stephen Boyd <redacted>
---
This duplicates code, but I don't know of a way to re-use the dynamic
code without sourcing a bash script and possibly breaking someone's build.
If we are going to do this, wouldn't it make more sense to revert the
rename of the script, so that people can keep relying on the name of the
script being "git-completion.bash", _but_ make it produce a pre-compiled
form to a separate file when invoked in some particular way?
Then at the runtime:
(0) If the script notices that it has already learned the command list
it uses it; otherwise,
(1) If the script notices that there is a file that contains the command
list, it sources it; otherwise,
(2) The script lazily builds the command list for its own use.
And at the buildtime, Makefile can run the script in "generation mode",
and install the output to where (1) above expects to see.
From: Stephen Boyd <hidden> Date: 2016-06-15 22:47:37
Junio C Hamano wrote:
If we are going to do this, wouldn't it make more sense to revert the
rename of the script, so that people can keep relying on the name of the
script being "git-completion.bash", _but_ make it produce a pre-compiled
form to a separate file when invoked in some particular way?
Wouldn't relying on "git-completion.bash" to produce the pre-compiled
form cause problems if someone is running the build on a bash-less
system? I thought this issue was already raised by Shawn.
I guess we could ignore that issue now, and just say that you have to
build the pre-compiled form on systems with bash?
Then at the runtime:
(0) If the script notices that it has already learned the command list
it uses it; otherwise,
(1) If the script notices that there is a file that contains the command
list, it sources it; otherwise,
(2) The script lazily builds the command list for its own use.
And at the buildtime, Makefile can run the script in "generation mode",
and install the output to where (1) above expects to see.
I assume you're suggesting this to ease the upgrade path for users. It
works nicely, we could just install the generated lists in the same path
(contrib/completion/) and then users would be free to copy the two files
anywhere as long as they're in the same directory. The only downside I
see is there's now two files, but that's ok with me.
From: Shawn O. Pearce <hidden> Date: 2016-06-15 22:47:37
Stephen Boyd [off-list ref] wrote:
Some users don't want to compile their completion, even when the build
generated completion is 10x faster to load. For example, in my bashrc I
source the completion script directly so I can stay up to date with the
latest completion by merely pulling changes.
Do this by generating the lists dynamically when the merge strategy and
command lists still have their initial values (__GIT_MERGE_STRATEGYLIST,
__GIT_ALL_COMMANDLIST).
Signed-off-by: Stephen Boyd <redacted>
---
This duplicates code, but I don't know of a way to re-use the dynamic
code without sourcing a bash script and possibly breaking someone's build.
NAK on code duplication, especially this much. As Junio already
pointed out in this thread we need an approach that doesn't cause
this sort of redundant code.
I'm trying to catch up on email right now. I have no great
suggestions on how to implement this to avoid the code duplication
and still be able to support both compile-time and on-the-fly
computation, but I do know I don't want this code twice.
--
Shawn.
From: Stephen Boyd <hidden> Date: 2016-06-15 22:47:37
Shawn O. Pearce wrote:
NAK on code duplication, especially this much. As Junio already
pointed out in this thread we need an approach that doesn't cause
this sort of redundant code.
Ok. Following Junio's suggestion I think we would have to do the following:
(1) Revert the rename (git-completion.bash.in -> git-completion.bash)
(2) Add a "generation" mode to git-completion.bash.generate to generate
the lists and output them to a file
(3) Add logic in git-completion.bash.generate to source the generated
file if it exists
(4) Source git-completion.bash.generate in git-completion.bash to get
the functions moved there
In the end we would have git-completion.bash sourcing
git-completion.bash.generate which then sources the generated file. I
assume this is slower than compiling to just one file.
Or we could just not load the caches until they're needed. This just
delays the performance hit to completion time, but at least it speeds up
loading the script without the need to compile and still has the benefit
of some caching. It also allows users to keep the completion of their
custom merge strategies and git programs in their PATH.
----8<----
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:37
Stephen Boyd [off-list ref] writes:
Ok. Following Junio's suggestion I think we would have to do the following:
(1) Revert the rename (git-completion.bash.in -> git-completion.bash)
(2) Add a "generation" mode to git-completion.bash.generate to
generate the lists and output them to a file
(3) Add logic in git-completion.bash.generate to source the generated
file if it exists
(4) Source git-completion.bash.generate in git-completion.bash to get
the functions moved there
Sorry, I do not quite see why an extra *.generate script is necessary.
From: Stephen Boyd <hidden> Date: 2016-06-15 22:47:37
Junio C Hamano wrote:
Stephen Boyd [off-list ref] writes:
quoted
Ok. Following Junio's suggestion I think we would have to do the following:
(1) Revert the rename (git-completion.bash.in -> git-completion.bash)
(2) Add a "generation" mode to git-completion.bash.generate to
generate the lists and output them to a file
(3) Add logic in git-completion.bash.generate to source the generated
file if it exists
(4) Source git-completion.bash.generate in git-completion.bash to get
the functions moved there
Sorry, I do not quite see why an extra *.generate script is necessary.
I'm still assuming the generation mode has to be sh agnostic, therefore
requiring those functions to be in another *.generate script. Is that wrong?