{"thread":{"id":"33040","subject":"zsh completion broken for file completion","startedAt":"2013-02-28T18:43:01Z","lastAt":"2013-04-02T12:47:14Z","messageCount":6,"participants":["Matthieu Moy","Manlio Perillo","Junio C Hamano","Felipe Contreras"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"210432","messageId":"vpqtxowp9e2.fsf@grenoble-inp.fr","threadId":"33040","inReplyTo":null,"subject":"zsh completion broken for file completion","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-02-28T18:43:01Z","receivedAt":"2013-02-28T18:43:01Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Hi,\n\nThe completion for e.g. \"git add file<tab>\" is broken in master. I get\nthe following result:\n\ngit add fo__gitcomp_file:8: command not found: compgen\n\nThe guilty commit is fea16b47b60 (Fri Jan 11 19:48:43 2013, Manlio\nPerillo, git-completion.bash: add support for path completion), which\nintroduces a new __gitcomp_file function that uses the bash builtin\n\"compgen\", without redefining the function in git-completion.zsh.\n\nThe following proof-of-concept patch seems to fix the problem for me (I\nbasically copied the __gitcomp_nl function to __gitcomp_file and removed\nthe '-S \"${4- }\"'). The bash version does \"compopt -o filenames\", I\ndon't know what zsh equivalent is.\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex 4577502..0ba1dcf 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -60,6 +60,15 @@ __gitcomp_nl ()\n        compadd -Q -S \"${4- }\" -p \"${2-}\" -- ${=1} && _ret=0\n }\n \n+__gitcomp_file ()\n+{\n+       emulate -L zsh\n+\n+       local IFS=$'\\n'\n+       compset -P '*[=:]'\n+       compadd -Q -p \"${2-}\" -- ${=1} && _ret=0\n+}\n+\n _git ()\n {\n        local _ret=1\n\nFelipe, you know ZSH completion much better than me. Could you turn this\ninto a real patch?\n\nThanks,\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"210434","messageId":"512FA915.4080203@gmail.com","threadId":"33040","inReplyTo":"vpqtxowp9e2.fsf@grenoble-inp.fr","subject":"Re: zsh completion broken for file completion","fromName":"Manlio Perillo","fromEmail":"manlio.perillo@gmail.com","sentAt":"2013-02-28T18:59:33Z","receivedAt":"2013-02-28T18:59:33Z","isPatch":false,"sender":{"key":"manlio.perillo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6217088?v=4"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nIl 28/02/2013 19:43, Matthieu Moy ha scritto:\n> Hi,\n> \n> The completion for e.g. \"git add file<tab>\" is broken in master. I get\n> the following result:\n> \n> git add fo__gitcomp_file:8: command not found: compgen\n> \n> The guilty commit is fea16b47b60 (Fri Jan 11 19:48:43 2013, Manlio\n> Perillo, git-completion.bash: add support for path completion), which\n> introduces a new __gitcomp_file function that uses the bash builtin\n> \"compgen\", without redefining the function in git-completion.zsh.\n> \n> [...] \n> diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\n> index 4577502..0ba1dcf 100644\n> --- a/contrib/completion/git-completion.zsh\n> +++ b/contrib/completion/git-completion.zsh\n> @@ -60,6 +60,15 @@ __gitcomp_nl ()\n>         compadd -Q -S \"${4- }\" -p \"${2-}\" -- ${=1} && _ret=0\n>  }\n>  \n> +__gitcomp_file ()\n> +{\n> +       emulate -L zsh\n> +\n> +       local IFS=$'\\n'\n> +       compset -P '*[=:]'\n> +       compadd -Q -p \"${2-}\" -- ${=1} && _ret=0\n> +}\n> +\n\nThis patch is implemented in fea16b47b60, but only for the deprecated\nzsh compatibility code inside git-completion.bash.\n\nThe reason I did not provided a patch for git-completion.zsh was because\nthere was a bug in this script [1].\n\nIf any changes are made to git-completion.zsh, please update\ngit-completion.bash, too.\n\n\n[1] Basically, on my system I need the following change at the end of\n    the file:\n\n\t-_git\n\t+autoload -U +X compinit && compinit\n\t+compdef _git git gitk\n\n    I don't know the reason, however; and it seems that it is a problem\n    only for me\n\n> [...]\n\n\nRegards  Malio\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\nComment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/\n\niEYEARECAAYFAlEvqRUACgkQscQJ24LbaURASgCeILUTXAiZA6Ndf2DHByJfv4nT\n2bMAn1gPqSdfIBzb0cexwYNoAuD5j2+O\n=sKTR\n-----END PGP SIGNATURE-----\n"},{"id":"210614","messageId":"1362473035-5034-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"33040","inReplyTo":"vpqtxowp9e2.fsf@grenoble-inp.fr","subject":"[PATCH] git-completion.zsh: define __gitcomp_file compatibility function","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2013-03-05T08:43:55Z","receivedAt":"2013-03-05T08:43:55Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Commit fea16b47b60 (Fri Jan 11 19:48:43 2013, Manlio Perillo,\ngit-completion.bash: add support for path completion), introduced a new\n__gitcomp_file function that uses the bash builtin \"compgen\". The\nfunction was redefined for ZSH in the deprecated section of\ngit-completion.bash, but not in the new git-completion.zsh script.\n\nAs a result, users of git-completion.zsh trying to complete \"git add\nfo<tab>\" get an error:\n\ngit add fo__gitcomp_file:8: command not found: compgen\n\nThis patch adds the redefinition and removes the error.\n\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n> Felipe, you know ZSH completion much better than me. Could you turn this\n> into a real patch?\n\nNo response from Felipe, so I'm trying my own patch. Compared to the\nsnippet I already sent, I added the -f option to \"compadd\", which was\nthere in the __gitcomp_file function defined in the deprecated ZSH\ncompatibility section of the bash script, and gives the ZSH equivalent\nfor \"compopt -o filenames\".\n\nThis fixes an annoying regression for ZSH users, so it may deserve to\nbe in the future 1.8.2.\n\n contrib/completion/git-completion.zsh | 9 +++++++++\n 1 file changed, 9 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex 4577502..cf8116d 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -60,6 +60,15 @@ __gitcomp_nl ()\n \tcompadd -Q -S \"${4- }\" -p \"${2-}\" -- ${=1} && _ret=0\n }\n \n+__gitcomp_file ()\n+{\n+\temulate -L zsh\n+\n+\tlocal IFS=$'\\n'\n+\tcompset -P '*[=:]'\n+\tcompadd -Q -p \"${2-}\" -f -- ${=1} && _ret=0\n+}\n+\n _git ()\n {\n \tlocal _ret=1\n-- \n1.8.1.3.572.g35e1b60\n"},{"id":"210642","messageId":"7vzjyhu6r3.fsf@alter.siamese.dyndns.org","threadId":"33040","inReplyTo":"1362473035-5034-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH] git-completion.zsh: define __gitcomp_file compatibility function","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-03-05T16:54:40Z","receivedAt":"2013-03-05T16:54:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> Commit fea16b47b60 (Fri Jan 11 19:48:43 2013, Manlio Perillo,\n> git-completion.bash: add support for path completion), introduced a new\n> __gitcomp_file function that uses the bash builtin \"compgen\". The\n> function was redefined for ZSH in the deprecated section of\n> git-completion.bash, but not in the new git-completion.zsh script.\n>\n> As a result, users of git-completion.zsh trying to complete \"git add\n> fo<tab>\" get an error:\n>\n> git add fo__gitcomp_file:8: command not found: compgen\n>\n> This patch adds the redefinition and removes the error.\n>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n> ---\n>> Felipe, you know ZSH completion much better than me. Could you turn this\n>> into a real patch?\n>\n> No response from Felipe, so I'm trying my own patch. Compared to the\n> snippet I already sent, I added the -f option to \"compadd\", which was\n> there in the __gitcomp_file function defined in the deprecated ZSH\n> compatibility section of the bash script, and gives the ZSH equivalent\n> for \"compopt -o filenames\".\n>\n> This fixes an annoying regression for ZSH users, so it may deserve to\n> be in the future 1.8.2.\n\nThanks, and I agree a fix to this issue should be fast-tracked.\n\n>\n>  contrib/completion/git-completion.zsh | 9 +++++++++\n>  1 file changed, 9 insertions(+)\n>\n> diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\n> index 4577502..cf8116d 100644\n> --- a/contrib/completion/git-completion.zsh\n> +++ b/contrib/completion/git-completion.zsh\n> @@ -60,6 +60,15 @@ __gitcomp_nl ()\n>  \tcompadd -Q -S \"${4- }\" -p \"${2-}\" -- ${=1} && _ret=0\n>  }\n>  \n> +__gitcomp_file ()\n> +{\n> +\temulate -L zsh\n> +\n> +\tlocal IFS=$'\\n'\n> +\tcompset -P '*[=:]'\n> +\tcompadd -Q -p \"${2-}\" -f -- ${=1} && _ret=0\n> +}\n> +\n>  _git ()\n>  {\n>  \tlocal _ret=1\n"},{"id":"212789","messageId":"CAMP44s2kqpusjweXN522oum9mw2vPg4==jGzd2c3CbHzU5E3=g@mail.gmail.com","threadId":"33040","inReplyTo":"512FA915.4080203@gmail.com","subject":"Re: zsh completion broken for file completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-01T09:30:45Z","receivedAt":"2013-04-01T09:30:45Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, Feb 28, 2013 at 12:59 PM, Manlio Perillo\n<manlio.perillo@gmail.com> wrote:\n>\n> [1] Basically, on my system I need the following change at the end of\n>     the file:\n>\n>         -_git\n>         +autoload -U +X compinit && compinit\n>         +compdef _git git gitk\n>\n>     I don't know the reason, however; and it seems that it is a problem\n>     only for me\n\nAre you sourcing this script? If so, don't; do what is suggested at\nthe top: use fpath to load it automatically.\n\nCheers.\n\n--\nFelipe Contreras\n"},{"id":"212876","messageId":"515AD352.9060105@gmail.com","threadId":"33040","inReplyTo":"CAMP44s3=pHAUHohgJxddVdXMRj-toWOEvKea-E02mEZPBLk25w@mail.gmail.com","subject":"Re: zsh completion broken for file completion","fromName":"Manlio Perillo","fromEmail":"manlio.perillo@gmail.com","sentAt":"2013-04-02T12:47:14Z","receivedAt":"2013-04-02T12:47:14Z","isPatch":false,"sender":{"key":"manlio.perillo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6217088?v=4"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nIl 01/04/2013 11:29, Felipe Contreras ha scritto:\n> \n> \n> On Thu, Feb 28, 2013 at 12:59 PM, Manlio Perillo\n> <manlio.perillo@gmail.com <mailto:manlio.perillo@gmail.com>> wrote:\n> \n> \n>     [1] Basically, on my system I need the following change at the end of\n>         the file:\n> \n>             -_git\n>             +autoload -U +X compinit && compinit\n>             +compdef _git git gitk\n> \n>         I don't know the reason, however; and it seems that it is a problem\n>         only for me\n> \n> \n> Are you sourcing this script? If so, don't; do what is suggested at the\n> top: use fpath to load it automatically.\n> \n\nI'm using fpath as documented.\n\nHowever I tested the script again, and now seems to work correctly.\nIt is possible that in the past I was using an incorrect configuration.\n\n\nThanks   Manlio Perillo\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\nComment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/\n\niEYEARECAAYFAlFa01IACgkQscQJ24LbaUQOmACghDC30GqXXPIExHOPl9HrrO1y\nBYgAn2QPAYvtsSAAiPpgMnmMRI3z0LE8\n=kmm0\n-----END PGP SIGNATURE-----\n"}]}