git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Matthew Coleman" <matt@1eanda.com>,
	"Stephon Harris" <theonestep4@gmail.com>,
	"Duy Nguyen" <pclouds@gmail.com>,
	"Jakub Narębski" <jnareb@gmail.com>,
	"Git mailing list" <git@vger.kernel.org>,
	"Rick van Hattem" <wolph@wol.ph>,
	"Dave Borowitz" <dborowitz@google.com>
Subject: Re: [PATCH] completion: correct zsh detection when run from git-completion.zsh (Re: [PATCH v2] completion: reduce overhead of clearing cached --options)
Date: Tue, 12 Jun 2018 10:46:16 +0200	[thread overview]
Message-ID: <CAM0VKj==u0DgnHF0j+OOtyWMCsuGApHW65CN9S4d5iUxb2bRUg@mail.gmail.com> (raw)
In-Reply-To: <20180611182053.GA20665@aiede.svl.corp.google.com>

On Mon, Jun 11, 2018 at 8:20 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> From: SZEDER Gábor <szeder.dev@gmail.com>
> Subject: completion: correct zsh detection when run from git-completion.zsh
>
> v2.18.0-rc0~90^2 (completion: reduce overhead of clearing cached
> --options, 2018-04-18) worked around a bug in bash's "set" builtin on
> MacOS by using compgen instead.  It was careful to avoid breaking zsh
> by guarding this workaround with
>
>         if [[ -n ${ZSH_VERSION-}} ]]
>
> Alas, this interacts poorly with git-completion.zsh's bash emulation:
>
>         ZSH_VERSION='' . "$script"
>
> Correct it by instead using a new GIT_SOURCING_ZSH_COMPLETION shell
> variable to detect whether git-completion.bash is being sourced from
> git-completion.zsh.  This way, the zsh variant is used both when run
> from zsh directly and when run via git-completion.zsh.
>
> Reproduction recipe:
>
>  1. cd git/contrib/completion && cp git-completion.zsh _git
>  2. Put the following in a new ~/.zshrc file:
>
>         autoload -U compinit; compinit
>         autoload -U bashcompinit; bashcompinit
>         fpath=(~/src/git/contrib/completion $fpath)
>
>  3. Open zsh and "git <TAB>".
>
> With this patch:
> Triggers nice git-completion.bash based tab completion
>
> Without:
>  contrib/completion/git-completion.bash:354: read-only variable: QISUFFIX
>  zsh:12: command not found: ___main
>  zsh:15: _default: function definition file not found
>  _dispatch:70: bad math expression: operand expected at `/usr/bin/g...'
>  Segmentation fault
>
> Reported-by: Rick van Hattem <wolph@wol.ph>
> Reported-by: Dave Borowitz <dborowitz@google.com>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> SZEDER Gábor wrote:
>
>> 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":
>
> Thanks again. May we have your sign-off?

Sure:

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>

Thank you for the commit message; had a family visit the last couple
of days and could not get around to it.


>  contrib/completion/git-completion.bash | 5 ++++-
>  contrib/completion/git-completion.zsh  | 2 +-
>  2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 12814e9bbf..f4a2e6774b 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -3223,7 +3223,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 ()
>  {
> --
> 2.18.0.rc1.242.g61856ae69a
>

  reply	other threads:[~2018-06-12  8:46 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05  3:10 [PATCH] specify encoding for sed command Stephon Harris
2018-04-05  6:53 ` Ævar Arnfjörð Bjarmason
2018-04-05  9:42   ` Eric Sunshine
2018-04-05  9:43   ` SZEDER Gábor
2018-04-10  7:18   ` Matt Coleman
2018-04-11 20:42     ` Matt Coleman
2018-04-12 22:12       ` Matthew Coleman
2018-04-13  0:01         ` SZEDER Gábor
2018-04-13  3:00           ` Matthew Coleman
2018-04-13 10:30             ` [PATCH] completion: reduce overhead of clearing cached --options SZEDER Gábor
2018-04-13 21:44               ` Jakub Narebski
2018-04-13 22:23                 ` SZEDER Gábor
2018-04-14 13:27                   ` Jakub Narebski
2018-04-16 18:23                     ` Jacob Keller
2018-04-16 20:35                       ` Matthew Coleman
2018-04-16  5:10                   ` Junio C Hamano
2018-04-16 13:15                     ` SZEDER Gábor
2018-04-16 13:29                       ` Jakub Narębski
2018-04-16 22:43                         ` Junio C Hamano
2018-04-17 22:02                           ` [PATCH v2] " SZEDER Gábor
2018-04-17 23:45                             ` Junio C Hamano
2018-05-07 15:05                               ` Matthew Coleman
2018-05-08  2:28                                 ` Todd Zullinger
2018-05-08  3:28                                   ` Junio C Hamano
2018-06-07  5:48                             ` Jonathan Nieder
2018-06-07 12:07                               ` Dave Borowitz
2018-06-07 12:41                               ` Rick van Hattem
2018-06-08 21:16                               ` SZEDER Gábor
2018-06-08 21:23                                 ` Jonathan Nieder
2018-06-08 21:41                                   ` SZEDER Gábor
2018-06-08 21:52                                     ` Jonathan Nieder
2018-06-08 21:58                                       ` SZEDER Gábor
2018-06-11 17:53                                   ` Junio C Hamano
2018-06-11 18:20                                 ` [PATCH] completion: correct zsh detection when run from git-completion.zsh (Re: [PATCH v2] completion: reduce overhead of clearing cached --options) Jonathan Nieder
2018-06-12  8:46                                   ` SZEDER Gábor [this message]
2018-06-12  9:48                                   ` SZEDER Gábor
2018-06-12  9:51                                   ` Rick van Hattem
2018-04-08 23:17 ` [PATCH] specify encoding for sed command Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM0VKj==u0DgnHF0j+OOtyWMCsuGApHW65CN9S4d5iUxb2bRUg@mail.gmail.com' \
    --to=szeder.dev@gmail.com \
    --cc=dborowitz@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    --cc=jrnieder@gmail.com \
    --cc=matt@1eanda.com \
    --cc=pclouds@gmail.com \
    --cc=theonestep4@gmail.com \
    --cc=wolph@wol.ph \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).