From: Matthieu Moy <Matthieu.Moy@imag.fr>
Date: Tue, 5 Mar 2013 08:43:55 +0000 (+0100)
Subject: git-completion.zsh: define __gitcomp_file compatibility function
X-Git-Tag: v1.8.2-rc3~2^2
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=926eb7ba4c52fbfee9fba86c16bb6c374857190e;p=git

git-completion.zsh: define __gitcomp_file compatibility function

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index 45775021ff..cf8116d477 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