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

Re: zsh completion broken for file completion

From
Manlio Perillo <manlio.perillo@gmail.com>
Date
Feb 28, 2013, 18:59 UTC
Message-ID
<512FA915.4080203@gmail.com>
In-Reply-To
<vpqtxowp9e2.fsf@grenoble-inp.fr>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Il 28/02/2013 19:43, Matthieu Moy ha scritto:
Show 30 quoted lines
> Hi,
> 
> The completion for e.g. "git add file<tab>" is broken in master. I get
> the following result:
> 
> git add fo__gitcomp_file:8: command not found: compgen
> 
> The guilty commit is fea16b47b60 (Fri Jan 11 19:48:43 2013, Manlio
> Perillo, git-completion.bash: add support for path completion), which
> introduces a new __gitcomp_file function that uses the bash builtin
> "compgen", without redefining the function in git-completion.zsh.
> 
> [...] 
> diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
> index 4577502..0ba1dcf 100644
> --- a/contrib/completion/git-completion.zsh
> +++ b/contrib/completion/git-completion.zsh
> @@ -60,6 +60,15 @@ __gitcomp_nl ()
>         compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
>  }
>  
> +__gitcomp_file ()
> +{
> +       emulate -L zsh
> +
> +       local IFS=$'\n'
> +       compset -P '*[=:]'
> +       compadd -Q -p "${2-}" -- ${=1} && _ret=0
> +}
> +

This patch is implemented in fea16b47b60, but only for the deprecated zsh compatibility code inside git-completion.bash.

The reason I did not provided a patch for git-completion.zsh was because there was a bug in this script [1].

If any changes are made to git-completion.zsh, please update git-completion.bash, too.

[1] Basically, on my system I need the following change at the end of
    the file:
	-_git
	+autoload -U +X compinit && compinit
	+compdef _git git gitk
    I don't know the reason, however; and it seems that it is a problem
    only for me
> [...]
Regards  Malio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlEvqRUACgkQscQJ24LbaURASgCeILUTXAiZA6Ndf2DHByJfv4nT 2bMAn1gPqSdfIBzb0cexwYNoAuD5j2+O =sKTR -----END PGP SIGNATURE-----

Previous: Matthieu MoyNext: Felipe Contreras
Message 2 of 6 in “zsh completion broken for file completion”
  1. Matthieu MoyFeb 28, 2013
  2. Manlio PerilloFeb 28, 2013
  3. Felipe ContrerasApr 1, 2013
  4. git-completion.zsh: define __gitcomp_file compatibility functionMatthieu Moy, Mar 5, 2013
  5. Junio C HamanoMar 5, 2013
  6. Manlio PerilloApr 2, 2013

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.