{"thread":{"id":"32141","subject":"[PATCH v6 0/2] New zsh wrapper","startedAt":"2012-11-18T11:08:07Z","lastAt":"2012-11-19T21:56:31Z","messageCount":5,"participants":["Felipe Contreras","Junio C Hamano"],"isPatch":true,"patchVersion":6,"patchTotal":2},"messages":[{"id":"203483","messageId":"1353236889-15052-1-git-send-email-felipe.contreras@gmail.com","threadId":"32141","inReplyTo":null,"subject":"[PATCH v6 0/2] New zsh wrapper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T11:08:07Z","receivedAt":"2012-11-18T11:08:07Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nIt looks like there's some resistance with the other patches this series was\ndepending upon, so lets get rid of them, they are not really needed.\n\nThis version should be ready to merge.\n\nThe second patch is new, in order for users to get the same features when\nsourcing the bash script (they don't need to change anything). They'll get a\nwarning suggesting to check the new script git-completion.zsh. Eventually, that\nsupport would be dropped from the bash script.\n\nSome people were suggesting something like this, so here it is.\n\nCan we merge the zsh wrapper now?\n\nFelipe Contreras (2):\n  completion: add new zsh completion\n  completion: start moving to the new zsh completion\n\n contrib/completion/git-completion.bash | 104 +++++++++++++++++++--------------\n contrib/completion/git-completion.zsh  |  78 +++++++++++++++++++++++++\n 2 files changed, 139 insertions(+), 43 deletions(-)\n create mode 100644 contrib/completion/git-completion.zsh\n\n-- \n1.8.0\n"},{"id":"203484","messageId":"1353236889-15052-2-git-send-email-felipe.contreras@gmail.com","threadId":"32141","inReplyTo":"1353236889-15052-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 1/2] completion: add new zsh completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T11:08:08Z","receivedAt":"2012-11-18T11:08:08Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"It seems there's always issues with zsh's bash completion emulation.\nI've tried to fix as many as I could[1], and most of the fixes are already\nin the latest version of zsh, but still, there are issues.\n\nThere is no point going through all that pain; the emulation is easy to\nachieve, and this patch works better than zsh's bash completion\nemulation.\n\n[1] http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=commitdiff;h=23907bb840c80eef99eabba17e086e44c9b2d3fc\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.zsh | 78 +++++++++++++++++++++++++++++++++++\n 1 file changed, 78 insertions(+)\n create mode 100644 contrib/completion/git-completion.zsh\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nnew file mode 100644\nindex 0000000..4577502\n--- /dev/null\n+++ b/contrib/completion/git-completion.zsh\n@@ -0,0 +1,78 @@\n+#compdef git gitk\n+\n+# zsh completion wrapper for git\n+#\n+# You need git's bash completion script installed somewhere, by default on the\n+# same directory as this script.\n+#\n+# If your script is on ~/.git-completion.sh instead, you can configure it on\n+# your ~/.zshrc:\n+#\n+#  zstyle ':completion:*:*:git:*' script ~/.git-completion.sh\n+#\n+# The recommended way to install this script is to copy to\n+# '~/.zsh/completion/_git', and then add the following to your ~/.zshrc file:\n+#\n+#  fpath=(~/.zsh/completion $fpath)\n+\n+complete ()\n+{\n+\t# do nothing\n+\treturn 0\n+}\n+\n+zstyle -s \":completion:*:*:git:*\" script script\n+test -z \"$script\" && script=\"$(dirname ${funcsourcetrace[1]%:*})\"/git-completion.bash\n+ZSH_VERSION='' . \"$script\"\n+\n+__gitcomp ()\n+{\n+\temulate -L zsh\n+\n+\tlocal cur_=\"${3-$cur}\"\n+\n+\tcase \"$cur_\" in\n+\t--*=)\n+\t\t;;\n+\t*)\n+\t\tlocal c IFS=$' \\t\\n'\n+\t\tlocal -a array\n+\t\tfor c in ${=1}; do\n+\t\t\tc=\"$c${4-}\"\n+\t\t\tcase $c in\n+\t\t\t--*=*|*.) ;;\n+\t\t\t*) c=\"$c \" ;;\n+\t\t\tesac\n+\t\t\tarray+=(\"$c\")\n+\t\tdone\n+\t\tcompset -P '*[=:]'\n+\t\tcompadd -Q -S '' -p \"${2-}\" -a -- array && _ret=0\n+\t\t;;\n+\tesac\n+}\n+\n+__gitcomp_nl ()\n+{\n+\temulate -L zsh\n+\n+\tlocal IFS=$'\\n'\n+\tcompset -P '*[=:]'\n+\tcompadd -Q -S \"${4- }\" -p \"${2-}\" -- ${=1} && _ret=0\n+}\n+\n+_git ()\n+{\n+\tlocal _ret=1\n+\t() {\n+\t\temulate -L ksh\n+\t\tlocal cur cword prev\n+\t\tcur=${words[CURRENT-1]}\n+\t\tprev=${words[CURRENT-2]}\n+\t\tlet cword=CURRENT-1\n+\t\t__${service}_main\n+\t}\n+\tlet _ret && _default -S '' && _ret=0\n+\treturn _ret\n+}\n+\n+_git\n-- \n1.8.0\n"},{"id":"203485","messageId":"1353236889-15052-3-git-send-email-felipe.contreras@gmail.com","threadId":"32141","inReplyTo":"1353236889-15052-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 2/2] completion: start moving to the new zsh completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-18T11:08:09Z","receivedAt":"2012-11-18T11:08:09Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Zsh's bash completion emulation is buggy, not properly maintained, and\nwe have some workarounds in place for different bugs that appeared in\nvarious versions.\n\nSince I'm the only one that has worked on that code lately[1], it might make\nsnese to use the code I wrote specifically for git.\n\nThe advantages are:\n\n 1) Less workarounds\n\n   * No need to hack __get_comp_words_by_ref\n   * No need to hack IFS or words\n\n 2) Improved features\n\n   * 'git show master' now properly adds a space at the end (IFS bug)\n   * 'git checkout --conflict=' now properly returns the sub-items\n     (missing feature)\n\n 3) Consolidated code\n\n   * It's all now in a single chunk, and it's basically the same as\n     git-completion.zsh\n\nSince there's some interest in moving the zsh-specific code out of this\nscript, lets go ahead and warn the users that they should be using\ngit-completion.zsh.\n\n[1] http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=history;f=Completion/bashcompinit\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 104 +++++++++++++++++++--------------\n 1 file changed, 61 insertions(+), 43 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex bc0657a..9cd58ca 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -23,10 +23,6 @@\n #    3) Consider changing your PS1 to also show the current branch,\n #       see git-prompt.sh for details.\n \n-if [[ -n ${ZSH_VERSION-} ]]; then\n-\tautoload -U +X bashcompinit && bashcompinit\n-fi\n-\n case \"$COMP_WORDBREAKS\" in\n *:*) : great ;;\n *)   COMP_WORDBREAKS=\"$COMP_WORDBREAKS:\"\n@@ -169,7 +165,6 @@ __git_reassemble_comp_words_by_ref()\n }\n \n if ! type _get_comp_words_by_ref >/dev/null 2>&1; then\n-if [[ -z ${ZSH_VERSION:+set} ]]; then\n _get_comp_words_by_ref ()\n {\n \tlocal exclude cur_ words_ cword_\n@@ -197,32 +192,6 @@ _get_comp_words_by_ref ()\n \t\tshift\n \tdone\n }\n-else\n-_get_comp_words_by_ref ()\n-{\n-\twhile [ $# -gt 0 ]; do\n-\t\tcase \"$1\" in\n-\t\tcur)\n-\t\t\tcur=${COMP_WORDS[COMP_CWORD]}\n-\t\t\t;;\n-\t\tprev)\n-\t\t\tprev=${COMP_WORDS[COMP_CWORD-1]}\n-\t\t\t;;\n-\t\twords)\n-\t\t\twords=(\"${COMP_WORDS[@]}\")\n-\t\t\t;;\n-\t\tcword)\n-\t\t\tcword=$COMP_CWORD\n-\t\t\t;;\n-\t\t-n)\n-\t\t\t# assume COMP_WORDBREAKS is already set sanely\n-\t\t\tshift\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-}\n-fi\n fi\n \n # Generates completion reply with compgen, appending a space to possible\n@@ -2430,20 +2399,69 @@ __gitk_main ()\n \t__git_complete_revlist\n }\n \n-__git_func_wrap ()\n-{\n-\tif [[ -n ${ZSH_VERSION-} ]]; then\n-\t\temulate -L bash\n-\t\tsetopt KSH_TYPESET\n+if [[ -n ${ZSH_VERSION-} ]]; then\n+\techo \"WARNING: this script is deprecated, please see git-completion.zsh\" 1>&2\n \n-\t\t# workaround zsh's bug that leaves 'words' as a special\n-\t\t# variable in versions < 4.3.12\n-\t\ttypeset -h words\n+\t__gitcomp ()\n+\t{\n+\t\temulate -L zsh\n \n-\t\t# workaround zsh's bug that quotes spaces in the COMPREPLY\n-\t\t# array if IFS doesn't contain spaces.\n-\t\ttypeset -h IFS\n-\tfi\n+\t\tlocal cur_=\"${3-$cur}\"\n+\n+\t\tcase \"$cur_\" in\n+\t\t--*=)\n+\t\t\t;;\n+\t\t*)\n+\t\t\tlocal c IFS=$' \\t\\n'\n+\t\t\tlocal -a array\n+\t\t\tfor c in ${=1}; do\n+\t\t\t\tc=\"$c${4-}\"\n+\t\t\t\tcase $c in\n+\t\t\t\t--*=*|*.) ;;\n+\t\t\t\t*) c=\"$c \" ;;\n+\t\t\t\tesac\n+\t\t\t\tarray+=(\"$c\")\n+\t\t\tdone\n+\t\t\tcompset -P '*[=:]'\n+\t\t\tcompadd -Q -S '' -p \"${2-}\" -a -- array && _ret=0\n+\t\t\t;;\n+\t\tesac\n+\t}\n+\n+\t__gitcomp_nl ()\n+\t{\n+\t\temulate -L zsh\n+\n+\t\tlocal IFS=$'\\n'\n+\t\tcompset -P '*[=:]'\n+\t\tcompadd -Q -S \"${4- }\" -p \"${2-}\" -- ${=1} && _ret=0\n+\t}\n+\n+\t__git_zsh_helper ()\n+\t{\n+\t\temulate -L ksh\n+\t\tlocal cur cword prev\n+\t\tcur=${words[CURRENT-1]}\n+\t\tprev=${words[CURRENT-2]}\n+\t\tlet cword=CURRENT-1\n+\t\t__${service}_main\n+\t}\n+\n+\t_git ()\n+\t{\n+\t\temulate -L zsh\n+\t\tlocal _ret=1\n+\t\t__git_zsh_helper\n+\t\tlet _ret && _default -S '' && _ret=0\n+\t\treturn _ret\n+\t}\n+\n+\tcompdef _git git gitk\n+\treturn\n+fi\n+\n+__git_func_wrap ()\n+{\n \tlocal cur words cword prev\n \t_get_comp_words_by_ref -n =: cur words cword prev\n \t$1\n-- \n1.8.0\n"},{"id":"203508","messageId":"7vpq39xw01.fsf@alter.siamese.dyndns.org","threadId":"32141","inReplyTo":"1353236889-15052-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v6 0/2] New zsh wrapper","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-11-19T18:55:58Z","receivedAt":"2012-11-19T18:55:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> The second patch is new, in order for users to get the same features when\n> sourcing the bash script (they don't need to change anything). They'll get a\n> warning suggesting to check the new script git-completion.zsh. Eventually, that\n> support would be dropped from the bash script.\n>\n> Some people were suggesting something like this, so here it is.\n>\n> Can we merge the zsh wrapper now?\n>\n> Felipe Contreras (2):\n>   completion: add new zsh completion\n>   completion: start moving to the new zsh completion\n>\n>  contrib/completion/git-completion.bash | 104 +++++++++++++++++++--------------\n>  contrib/completion/git-completion.zsh  |  78 +++++++++++++++++++++++++\n>  2 files changed, 139 insertions(+), 43 deletions(-)\n>  create mode 100644 contrib/completion/git-completion.zsh\n\nThanks; I am a bit puzzled as to the progression of this series, as\nit spanned many months.  I *think* the following are the previous\nones, but I may be mixing up v$n patches for other series, so just\nto make sure (please correct if I am mistaken):\n\n * (v1) http://thread.gmane.org/gmane.comp.version-control.git/189310\n   with only git-completion.zsh without any changes to the bash\n   side;\n\n * (v2) http://thread.gmane.org/gmane.comp.version-control.git/189381\n   without bash side changes;\n\n * (v3) http://thread.gmane.org/gmane.comp.version-control.git/196720\n   without bash side changes;\n\n * (v6) http://thread.gmane.org/gmane.comp.version-control.git/208170\n   with COMPREPLY changes;\n\n * This one, with removal of zsh specific workarounds from bash\n   completion script.\n\nI do not care too much about how v4 and v5 looked like; I primarily\nam interested in knowing if I can discard 208170 from my inbox\nsafely ;-).\n\nThanks.\n"},{"id":"203518","messageId":"CAMP44s0K2bzDDJQcC-KRnY50sZ4zNPSaujH5Gj7v5y6=ZYM90Q@mail.gmail.com","threadId":"32141","inReplyTo":"7vpq39xw01.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v6 0/2] New zsh wrapper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-19T21:56:31Z","receivedAt":"2012-11-19T21:56:31Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Nov 19, 2012 at 7:55 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> The second patch is new, in order for users to get the same features when\n>> sourcing the bash script (they don't need to change anything). They'll get a\n>> warning suggesting to check the new script git-completion.zsh. Eventually, that\n>> support would be dropped from the bash script.\n>>\n>> Some people were suggesting something like this, so here it is.\n>>\n>> Can we merge the zsh wrapper now?\n>>\n>> Felipe Contreras (2):\n>>   completion: add new zsh completion\n>>   completion: start moving to the new zsh completion\n>>\n>>  contrib/completion/git-completion.bash | 104 +++++++++++++++++++--------------\n>>  contrib/completion/git-completion.zsh  |  78 +++++++++++++++++++++++++\n>>  2 files changed, 139 insertions(+), 43 deletions(-)\n>>  create mode 100644 contrib/completion/git-completion.zsh\n>\n> Thanks; I am a bit puzzled as to the progression of this series, as\n> it spanned many months.  I *think* the following are the previous\n> ones, but I may be mixing up v$n patches for other series, so just\n> to make sure (please correct if I am mistaken):\n>\n>  * (v1) http://thread.gmane.org/gmane.comp.version-control.git/189310\n>    with only git-completion.zsh without any changes to the bash\n>    side;\n\nYes, and with a lot of code that is not strictly needed.\n\n>  * (v2) http://thread.gmane.org/gmane.comp.version-control.git/189381\n>    without bash side changes;\n\nYes, also with more code.\n\n>  * (v3) http://thread.gmane.org/gmane.comp.version-control.git/196720\n>    without bash side changes;\n\nYes, now it's simpler due to changes in bash side already in.\n\n>  * (v6) http://thread.gmane.org/gmane.comp.version-control.git/208170\n>    with COMPREPLY changes;\n\nYeap.\n\n>  * This one, with removal of zsh specific workarounds from bash\n>    completion script.\n\nYes, although that is a separate patch.\n\n> I do not care too much about how v4 and v5 looked like; I primarily\n> am interested in knowing if I can discard 208170 from my inbox\n> safely ;-).\n\nYes you can. The rest of the patches I sent in a different series.\n\nCheers.\n\n-- \nFelipe Contreras\n"}]}