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

Re: [PATCH] git-completion.zsh: define __gitcomp_file compatibility function

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 5, 2013, 16:54 UTC
Message-ID
<7vzjyhu6r3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1362473035-5034-1-git-send-email-Matthieu.Moy@imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
Show 26 quoted lines
> Commit fea16b47b60 (Fri Jan 11 19:48:43 2013, Manlio Perillo,
> git-completion.bash: add support for path completion), introduced a new
> __gitcomp_file function that uses the bash builtin "compgen". The
> function was redefined for ZSH in the deprecated section of
> git-completion.bash, but not in the new git-completion.zsh script.
>
> As a result, users of git-completion.zsh trying to complete "git add
> fo<tab>" get an error:
>
> git add fo__gitcomp_file:8: command not found: compgen
>
> This patch adds the redefinition and removes the error.
>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
>> Felipe, you know ZSH completion much better than me. Could you turn this
>> into a real patch?
>
> No response from Felipe, so I'm trying my own patch. Compared to the
> snippet I already sent, I added the -f option to "compadd", which was
> there in the __gitcomp_file function defined in the deprecated ZSH
> compatibility section of the bash script, and gives the ZSH equivalent
> for "compopt -o filenames".
>
> This fixes an annoying regression for ZSH users, so it may deserve to
> be in the future 1.8.2.
Thanks, and I agree a fix to this issue should be fast-tracked.
Show 24 quoted lines
>
>  contrib/completion/git-completion.zsh | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
> index 4577502..cf8116d 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-}" -f -- ${=1} && _ret=0
> +}
> +
>  _git ()
>  {
>  	local _ret=1
Previous: Matthieu MoyNext: Manlio Perillo
Message 5 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.