git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH for maint branch] git-completion: fix zsh support

From
SZEDER Gábor <szeder@ira.uka.de>
Date
May 5, 2011, 18:59 UTC
Message-ID
<20110505185907.GD1377@goldbirke>
In-Reply-To
<1304605458-1483-1-git-send-email-felipe.contreras@gmail.com>
Hi,
On Thu, May 05, 2011 at 05:24:18PM +0300, Felipe Contreras wrote:
Show 6 quoted lines
> It turns out 'words' is a special variable used by zsh completion.
> 
> There's probably a bug in zsh's bashcompinit:
> http://article.gmane.org/gmane.comp.shells.zsh.devel/22546
> 
> But in the meantime we can workaround it this way.

I would prefer some details about this "workaround it this way" in the commit message (i.e. that you used "typedef -h", what it does in zsh, and why it fixes the issue; my zsh-fu is, well, not particularly large, so I have no idea), so when someone later runs 'git log -- contrib/completion' then he will easier understand what's going on without the need to look at the patch.

Show 13 quoted lines
> Currently 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.
> 
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  contrib/completion/git-completion.bash |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> This patch is meant for the maintenance branch, so Szeder's patches are not
> needed.

My first two patches are cleanups, they definitely worth keeping, even when this patch alone would fix the zsh issues.

Show 11 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 840ae38..8d5eae7 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2710,6 +2710,9 @@ _git ()
>  	if [[ -n ${ZSH_VERSION-} ]]; then
>  		emulate -L bash
>  		setopt KSH_TYPESET
> +
> +		# 'words' has special meaning in zsh; override that
> +		typeset -h words

You have to do the same in _gitk(), too. Although _gitk() itself doesn't use $words, it invokes __git_has_doubledash(), which does, hence it's still broken.

Show 6 quoted lines
>  	fi
>  
>  	local cur words cword
> -- 
> 1.7.5.1.1.g638e6
> 
Previous: Felipe ContrerasNext: Felipe Contreras
Message 4 of 14 in “git-completion: fix zsh support”
  1. git-completion: fix zsh supportFelipe Contreras, May 5, 2011
  2. Junio C HamanoMay 5, 2011
  3. Felipe ContrerasMay 5, 2011
  4. SZEDER GáborMay 5, 2011
  5. git-completion: fix zsh supportFelipe Contreras, May 5, 2011
  6. Jonathan NiederMay 5, 2011
  7. Junio C HamanoMay 6, 2011
  8. Jonathan NiederMay 6, 2011
  9. Felipe ContrerasMay 6, 2011
  10. Felipe ContrerasMay 6, 2011
  11. Jonathan NiederMay 6, 2011
  12. Jonathan NiederMay 6, 2011
  13. Felipe ContrerasMay 9, 2011
  14. Jonathan NiederMay 6, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.