git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org, gitster@pobox.com
Cc: felipe.contreras@gmail.com, manlio.perillo@gmail.com,
	Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH] git-completion.zsh: define __gitcomp_file compatibility function
Date: Tue,  5 Mar 2013 09:43:55 +0100	[thread overview]
Message-ID: <1362473035-5034-1-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <vpqtxowp9e2.fsf@grenoble-inp.fr>

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.

 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
-- 
1.8.1.3.572.g35e1b60

  parent reply	other threads:[~2013-03-05  8:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-28 18:43 zsh completion broken for file completion Matthieu Moy
2013-02-28 18:59 ` Manlio Perillo
2013-04-01  9:30   ` Felipe Contreras
     [not found]   ` <CAMP44s3=pHAUHohgJxddVdXMRj-toWOEvKea-E02mEZPBLk25w@mail.gmail.com>
2013-04-02 12:47     ` Manlio Perillo
2013-03-05  8:43 ` Matthieu Moy [this message]
2013-03-05 16:54   ` [PATCH] git-completion.zsh: define __gitcomp_file compatibility function Junio C Hamano

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=1362473035-5034-1-git-send-email-Matthieu.Moy@imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=manlio.perillo@gmail.com \
    /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).