Re: [PATCH v2] completion: reduce overhead of clearing cached --options
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Jun 8, 2018, 21:16 UTC
- Message-ID
- <20180608211639.7611-1-szeder.dev@gmail.com>
- In-Reply-To
- <20180607054834.GB6567@aiede.svl.corp.google.com>
> Related question: what would it take to add a zsh completion sanity > check to t/t9902-completion.sh?
I don't know. What I do know is that we can't just run our tests with ZSH, e.g. running 'zsh ./t0000-basic.sh' shows mostly failures. So it won't be as simple as modifying 't/lib-bash.sh' to somehow support ZSH as well.
Show 40 quoted lines
> Here's a minimal fix, untested. As a followup, as G�bor suggests at [2],
> it would presumably make sense to stop overriding ZSH_VERSION, using
> this GIT_ scoped variable everywhere instead.
>
> Thoughts?
>
> Reported-by: Rick van Hattem <wolph@wol.ph>
> Reported-by: Dave Borowitz <dborowitz@google.com>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
>
> [1] https://public-inbox.org/git/01020163c683e753-04629405-15f8-4a30-9dc3-e4e3f2a5aa26-000000@eu-west-1.amazonses.com/
> [2] https://public-inbox.org/git/20180606114147.7753-1-szeder.dev@gmail.com/
>
> diff --git i/contrib/completion/git-completion.bash w/contrib/completion/git-completion.bash
> index 12814e9bbf..e4bcc435ea 100644
> --- i/contrib/completion/git-completion.bash
> +++ w/contrib/completion/git-completion.bash
> @@ -348,7 +348,7 @@ __gitcomp ()
>
> # Clear the variables caching builtins' options when (re-)sourcing
> # the completion script.
> -if [[ -n ${ZSH_VERSION-} ]]; then
> +if [[ -n ${ZSH_VERSION-} || -n ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then
> unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null
> else
> unset $(compgen -v __gitcomp_builtin_)
> diff --git i/contrib/completion/git-completion.zsh w/contrib/completion/git-completion.zsh
> index 53cb0f934f..c7be9fd4dc 100644
> --- i/contrib/completion/git-completion.zsh
> +++ w/contrib/completion/git-completion.zsh
> @@ -39,7 +39,7 @@ if [ -z "$script" ]; then
> test -f $e && script="$e" && break
> done
> fi
> -ZSH_VERSION='' . "$script"
> +GIT_SOURCING_ZSH_COMPLETION=1 ZSH_VERSION='' . "$script"
>
> __gitcomp ()
> {
> Being in RC phase, I'm all for aiming for a minimal solution. However, I don't think that the better fix would be erm.. any "less minimal":
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index f2aa484758..7aeb575cd1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3244,7 +3244,10 @@ __gitk_main () __git_complete_revlist } -if [[ -n ${ZSH_VERSION-} ]]; then +if [[ -n ${ZSH_VERSION-} ]] && + # Don't define these functions when sourced from 'git-completion.zsh', + # it has its own implementations. + [[ -z "${GIT_SOURCING_ZSH_COMPLETION}" ]] ; then echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 autoload -U +X compinit && compinit diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh index 53cb0f934f..049d6b80f6 100644 --- a/contrib/completion/git-completion.zsh +++ b/contrib/completion/git-completion.zsh @@ -39,7 +39,7 @@ if [ -z "$script" ]; then test -f $e && script="$e" && break done fi -ZSH_VERSION='' . "$script" +GIT_SOURCING_ZSH_COMPLETION=y . "$script" __gitcomp () {