git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 (for maint)] git-completion: fix zsh support
@ 2011-05-09 20:45 Felipe Contreras
  2011-05-09 21:13 ` Jonathan Nieder
  0 siblings, 1 reply; 19+ messages in thread
From: Felipe Contreras @ 2011-05-09 20:45 UTC (permalink / raw)
  To: git; +Cc: SZEDER Gábor, Jonathan Nieder, Felipe Contreras

It turns out 'words' is a special variable used by zsh completion, sort
of like 'COMP_WORDS' in bash. 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.

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.

Right now zsh is completely broken after commit da48616 (bash: get
--pretty=m<tab> completion to work with bash v4), which introduced
_get_comp_words_by_ref() that comes from debian's bash_completion
scripts, and relies on the 'words' variable to behave like any normal
variable.

[1] http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=commitdiff;h=e880604f029088f32fb1ecc39213d720ae526aaa

Comments-by: SZEDER Gábor <szeder@ira.uka.de>
Comments-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/completion/git-completion.bash |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

This patch is meant for the maintenance branch, so Szeder's patches are not
required.

v2: fix _gitk() too as Szeder suggested.

v3: improve commit message as Jonathan Nieder suggested.
    Also, improve comments.

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 840ae38..763f145 100755
--- 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
 	fi
 
 	local cur words cword
@@ -2761,6 +2765,10 @@ _gitk ()
 	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
 	fi
 
 	__git_has_doubledash && return
-- 
1.7.5.1.1.g638e6

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-05-10 11:43 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).