From: Felipe Contreras <felipe.contreras@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: git@vger.kernel.org, "SZEDER Gábor" <szeder@ira.uka.de>
Subject: Re: [PATCH v3 (for maint)] git-completion: fix zsh support
Date: Tue, 10 May 2011 01:08:17 +0300 [thread overview]
Message-ID: <BANLkTikkhryMa69DSx4EAYjw+aar4icKcQ@mail.gmail.com> (raw)
In-Reply-To: <20110509211316.GB22908@elie>
On Tue, May 10, 2011 at 12:13 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Felipe Contreras wrote:
>
>> It turns out 'words' is a special variable used by zsh completion, sort
>> of like 'COMP_WORDS' in bash.
>
> I was not aware that COMP_WORDS was special (rather than just
> prepopulated). Is it?
I didn't mean to suggest it was special, only what 'words' was used
for. I'll remove that section as it doesn't really matter.
>> This was not isolated correctly in zsh's
>> bash completion, so by trying to set it as 'local' in git's completion,
>> unexpected results occur; assignations are not propagated to upper
>> levels in the call stack.
>
> Does the call stack grow up or down? I suspect this means:
I'll change that to "outer levels".
> zsh's bash completion emulation layer does not sufficiently
> insulate us from that reality. In particular, the variable
> keeps the "special" attribute (even after a declaration "local
> words"), so assignments within a function are undone whenever
> the function returns.
That explains less.
> In particular, until 3bee6a473 (completion: don't declare
> 'local words' to make zsh happy, 2011-04-28), the "words" array
> would be cleared in _git by declaring "local words" and its new
> value would never be propagated from _get_comp_words_by_ref so
> it remained empty and the completion script could not tell that
> there were existing subcommand names on the command line (so
> "git log m<TAB>" would complete subcommand names).
I don't see the point in explaining in excruciating detail all the
series of steps in which an unset variable causes problems; the
variable doesn't get set, thus one can assume there are problems. And
the problem is already explained to be that completion is completely
broken.
> And even after 3bee6a473 we do not have the ability to modify
> words. (... explanation of impact of the change goes here ...)
>
> I am not a great writer so that is probably more verbose than needed.
> So it might be better for me to describe the goals of a commit message:
>
> 1) the text should be specific about what the commit fixes, so
> someone reading it later (e.g., after bisecting) does not come
> around and accidentally break it
See the title: fix zsh support
> 2) in particular, the text should be specific about the observable
> symptoms, so it can be easier to check if a later change has
> broken it.
From the title: zsh completion doesn't work at all. Which is repeated again:
---
Right now zsh is completely broken...
---
If zsh completion is completely broken, chance are it has to do with
this. And I did explain the most obvious test; check if the value of
'words' doesn't get propagated to the upper layers in the call stack.
>> This is now fixed in the latest master branch of zsh[1] by simply
>> defining 'words' as hidden (typeset -h), which removes the special
>> meaning inside the emulated bash function. It probably won't be released
>> until version 4.3.12.
>>
>> In the meantime, we can workaround the issue by doing the same; defining
>> words as hidden (typeset -h) as soon as possible.
>
> It might make sense to reverse the order of these: first explain the
> fix in the context of the problem being solved, and then add a note
> mentioning that the fix will not be needed for long and that the
> method is the same as what zsh is planning to use.
That's what I did initially, but everyone doubted my solution. Now I
want to start making sure people see it's a good solution.
> Meanwhile this doesn't address the risk that functions called by the
> completion script will use $words.
It does.
> Outside the context of the commit
> message I think you've said something about that (e.g., that the zsh
> developers prefer this fix --- a reference would be nice so we could
> steal their rationale).
I did. If you don't like their commit message, talk to them.
> Maybe the best thing to say would be "that is
> a risk, but let's wait and see", to give future readers more
> confidence that that was considered but it is ok to fix it if it comes
> up?
I don't see any risk.
>> --- a/contrib/completion/git-completion.bash
>> +++ b/contrib/completion/git-completion.bash
>> @@ -2710,6 +2710,10 @@ _git ()
>> if [[ -n ${ZSH_VERSION-} ]]; then
>> emulate -L bash
>> setopt KSH_TYPESET
>> +
>> + # workaround zsh's bashinit's bug that leaves 'words' as a
>> + # special variable in versions < 4.3.12
>> + typeset -h words
>
> I don't think the comment clarifies much. What is the intended
> message to the reader? For example if it is "don't remove this line
> unless you use zsh 4.3.12 or greater", I'd say something like
>
> # bashcompinit versions after 4.3.12 already hide the
> # special "words" variable already. We do it
> # again ourselves to support older zsh versions.
I think it's perfectly clear. Specially if you compare it against the
two lines above that have no explanation at all. Double standards
much?
--
Felipe Contreras
next prev parent reply other threads:[~2011-05-09 22:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-09 20:45 [PATCH v3 (for maint)] git-completion: fix zsh support Felipe Contreras
2011-05-09 21:13 ` Jonathan Nieder
2011-05-09 22:08 ` Felipe Contreras [this message]
2011-05-09 22:14 ` [PATCH v4 " Felipe Contreras
2011-05-09 22:53 ` Jonathan Nieder
2011-05-09 23:13 ` Felipe Contreras
2011-05-09 23:28 ` Jonathan Nieder
2011-05-09 23:58 ` Felipe Contreras
2011-05-09 23:25 ` Junio C Hamano
2011-05-09 23:35 ` Jonathan Nieder
2011-05-10 2:55 ` [PATCH v5 0/2] " Jonathan Nieder
2011-05-10 2:59 ` [PATCH 1/2] completion: suppress zsh's special 'words' variable Jonathan Nieder
2011-05-10 3:17 ` Jonathan Nieder
2011-05-10 11:43 ` Felipe Contreras
2011-05-10 11:29 ` Felipe Contreras
2011-05-10 3:00 ` [PATCH 2/2] completion: move private shopt shim for zsh to __git_ namespace Jonathan Nieder
2011-05-10 10:48 ` [PATCH v5 0/2] git-completion: fix zsh support Felipe Contreras
2011-05-10 2:04 ` [PATCH v3 (for maint)] " Jonathan Nieder
2011-05-10 10:44 ` Felipe Contreras
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTikkhryMa69DSx4EAYjw+aar4icKcQ@mail.gmail.com \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=szeder@ira.uka.de \
/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.
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 NNTP newsgroup(s).