{"thread":{"id":"27195","subject":"[PATCH] git-completion: fix zsh support","startedAt":"2011-04-27T01:26:52Z","lastAt":"2011-05-08T10:48:15Z","messageCount":28,"participants":["Felipe Contreras","Jonathan Nieder","Junio C Hamano","John Szakmeister","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"166426","messageId":"1303867612-15975-1-git-send-email-felipe.contreras@gmail.com","threadId":"27195","inReplyTo":null,"subject":"[PATCH] git-completion: fix zsh support","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T01:26:52Z","receivedAt":"2011-04-27T01:26:52Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"It turns out 'words' is a special variable used by zsh completion, and\nit has some strange behavior as we can see.\n\nBetter avoid it.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |   66 ++++++++++++++++----------------\n 1 files changed, 33 insertions(+), 33 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex b94ff3c..9aae484 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -447,8 +447,8 @@ _get_comp_words_by_ref ()\n \t\tprev)\n \t\t\tprev=${words_[$cword_-1]}\n \t\t\t;;\n-\t\twords)\n-\t\t\twords=(\"${words_[@]}\")\n+\t\tcwords)\n+\t\t\tcwords=(\"${words_[@]}\")\n \t\t\t;;\n \t\tcword)\n \t\t\tcword=$cword_\n@@ -468,8 +468,8 @@ _get_comp_words_by_ref ()\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\tcwords)\n+\t\t\tcwords=(\"${COMP_WORDS[@]}\")\n \t\t\t;;\n \t\tcword)\n \t\t\tcword=$COMP_CWORD\n@@ -739,12 +739,12 @@ __git_complete_revlist ()\n \n __git_complete_remote_or_refspec ()\n {\n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n-\tlocal cmd=\"${words[1]}\"\n+\tlocal cur cwords cword\n+\t_get_comp_words_by_ref -n =: cur cwords cword\n+\tlocal cmd=\"${cwords[1]}\"\n \tlocal i c=2 remote=\"\" pfx=\"\" lhs=1 no_complete_refspec=0\n \twhile [ $c -lt $cword ]; do\n-\t\ti=\"${words[c]}\"\n+\t\ti=\"${cwords[c]}\"\n \t\tcase \"$i\" in\n \t\t--mirror) [ \"$cmd\" = \"push\" ] && no_complete_refspec=1 ;;\n \t\t--all)\n@@ -991,10 +991,10 @@ __git_aliased_command ()\n # __git_find_on_cmdline requires 1 argument\n __git_find_on_cmdline ()\n {\n-\tlocal word subcommand c=1 words cword\n-\t_get_comp_words_by_ref -n =: words cword\n+\tlocal word subcommand c=1 cwords cword\n+\t_get_comp_words_by_ref -n =: cwords cword\n \twhile [ $c -lt $cword ]; do\n-\t\tword=\"${words[c]}\"\n+\t\tword=\"${cwords[c]}\"\n \t\tfor subcommand in $1; do\n \t\t\tif [ \"$subcommand\" = \"$word\" ]; then\n \t\t\t\techo \"$subcommand\"\n@@ -1007,10 +1007,10 @@ __git_find_on_cmdline ()\n \n __git_has_doubledash ()\n {\n-\tlocal c=1 words cword\n-\t_get_comp_words_by_ref -n =: words cword\n+\tlocal c=1 cwords cword\n+\t_get_comp_words_by_ref -n =: cwords cword\n \twhile [ $c -lt $cword ]; do\n-\t\tif [ \"--\" = \"${words[c]}\" ]; then\n+\t\tif [ \"--\" = \"${cwords[c]}\" ]; then\n \t\t\treturn 0\n \t\tfi\n \t\tc=$((++c))\n@@ -1135,11 +1135,11 @@ _git_bisect ()\n \n _git_branch ()\n {\n-\tlocal i c=1 only_local_ref=\"n\" has_r=\"n\" cur words cword\n+\tlocal i c=1 only_local_ref=\"n\" has_r=\"n\" cur cwords cword\n \n-\t_get_comp_words_by_ref -n =: cur words cword\n+\t_get_comp_words_by_ref -n =: cur cwords cword\n \twhile [ $c -lt $cword ]; do\n-\t\ti=\"${words[c]}\"\n+\t\ti=\"${cwords[c]}\"\n \t\tcase \"$i\" in\n \t\t-d|-m)\tonly_local_ref=\"y\" ;;\n \t\t-r)\thas_r=\"y\" ;;\n@@ -1167,9 +1167,9 @@ _git_branch ()\n \n _git_bundle ()\n {\n-\tlocal words cword\n-\t_get_comp_words_by_ref -n =: words cword\n-\tlocal cmd=\"${words[2]}\"\n+\tlocal cwords cword\n+\t_get_comp_words_by_ref -n =: cwords cword\n+\tlocal cmd=\"${cwords[2]}\"\n \tcase \"$cword\" in\n \t2)\n \t\t__gitcomp \"create list-heads verify unbundle\"\n@@ -1713,15 +1713,15 @@ _git_notes ()\n {\n \tlocal subcommands='add append copy edit list prune remove show'\n \tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n+\tlocal cur cwords cword\n+\t_get_comp_words_by_ref -n =: cur cwords cword\n \n \tcase \"$subcommand,$cur\" in\n \t,--*)\n \t\t__gitcomp '--ref'\n \t\t;;\n \t,*)\n-\t\tcase \"${words[cword-1]}\" in\n+\t\tcase \"${cwords[cword-1]}\" in\n \t\t--ref)\n \t\t\t__gitcomp \"$(__git_refs)\"\n \t\t\t;;\n@@ -1749,7 +1749,7 @@ _git_notes ()\n \tprune,*)\n \t\t;;\n \t*)\n-\t\tcase \"${words[cword-1]}\" in\n+\t\tcase \"${cwords[cword-1]}\" in\n \t\t-m|-F)\n \t\t\t;;\n \t\t*)\n@@ -1893,11 +1893,11 @@ _git_stage ()\n \n __git_config_get_set_variables ()\n {\n-\tlocal words cword\n-\t_get_comp_words_by_ref -n =: words cword\n+\tlocal cwords cword\n+\t_get_comp_words_by_ref -n =: cwords cword\n \tlocal prevword word config_file= c=$cword\n \twhile [ $c -gt 1 ]; do\n-\t\tword=\"${words[c]}\"\n+\t\tword=\"${cwords[c]}\"\n \t\tcase \"$word\" in\n \t\t--global|--system|--file=*)\n \t\t\tconfig_file=\"$word\"\n@@ -2665,10 +2665,10 @@ _git_svn ()\n _git_tag ()\n {\n \tlocal i c=1 f=0\n-\tlocal words cword prev\n-\t_get_comp_words_by_ref -n =: words cword prev\n+\tlocal cwords cword prev\n+\t_get_comp_words_by_ref -n =: cwords cword prev\n \twhile [ $c -lt $cword ]; do\n-\t\ti=\"${words[c]}\"\n+\t\ti=\"${cwords[c]}\"\n \t\tcase \"$i\" in\n \t\t-d|-v)\n \t\t\t__gitcomp \"$(__git_tags)\"\n@@ -2712,10 +2712,10 @@ _git ()\n \t\tsetopt KSH_TYPESET\n \tfi\n \n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n+\tlocal cur cwords cword\n+\t_get_comp_words_by_ref -n =: cur cwords cword\n \twhile [ $c -lt $cword ]; do\n-\t\ti=\"${words[c]}\"\n+\t\ti=\"${cwords[c]}\"\n \t\tcase \"$i\" in\n \t\t--git-dir=*) __git_dir=\"${i#--git-dir=}\" ;;\n \t\t--bare)      __git_dir=\".\" ;;\n-- \n1.7.5\n"},{"id":"166427","messageId":"20110427013534.GA14286@elie","threadId":"27195","inReplyTo":"1303867612-15975-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH] git-completion: fix zsh support","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-04-27T01:35:59Z","receivedAt":"2011-04-27T01:35:59Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> It turns out 'words' is a special variable used by zsh completion, and\n> it has some strange behavior as we can see.\n> \n> Better avoid it.\n\nHoorah!  I imagine this fixes a regression introduced by\nv1.7.4-rc0~11^2~2 (bash: get --pretty=m<tab> completion to work with\nbash v4, 2010-12-02).\n\n Acked-by: Jonathan Nieder <jrnieder@gmail.com>\n\n>\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash |   66 ++++++++++++++++----------------\n>  1 files changed, 33 insertions(+), 33 deletions(-)\n\nStefan and Mark, if you'd like to try this out, the patch is at\nhttp://download.gmane.org/gmane.comp.version-control.git/172142/172143\n\nHappily,\nJonathan\n"},{"id":"166428","messageId":"BANLkTi=9PPJWX-y2YuFt3k0op2TaJ54=pw@mail.gmail.com","threadId":"27195","inReplyTo":"20110427013534.GA14286@elie","subject":"Re: [PATCH] git-completion: fix zsh support","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T01:42:34Z","receivedAt":"2011-04-27T01:42:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Apr 27, 2011 at 4:35 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>\n>> It turns out 'words' is a special variable used by zsh completion, and\n>> it has some strange behavior as we can see.\n>>\n>> Better avoid it.\n>\n> Hoorah!  I imagine this fixes a regression introduced by\n> v1.7.4-rc0~11^2~2 (bash: get --pretty=m<tab> completion to work with\n> bash v4, 2010-12-02).\n>\n>  Acked-by: Jonathan Nieder <jrnieder@gmail.com>\n\nYeap... The completion wasn't working at all after that :(\n\n-- \nFelipe Contreras\n"},{"id":"166440","messageId":"20110427022117.GA16697@elie","threadId":"27195","inReplyTo":"1303867612-15975-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH] git-completion: fix zsh support","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-04-27T02:21:17Z","receivedAt":"2011-04-27T02:21:17Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> +++ b/contrib/completion/git-completion.bash\n[...]\n> @@ -739,12 +739,12 @@ __git_complete_revlist ()\n>  \n>  __git_complete_remote_or_refspec ()\n>  {\n> -\tlocal cur words cword\n> -\t_get_comp_words_by_ref -n =: cur words cword\n> -\tlocal cmd=\"${words[1]}\"\n> +\tlocal cur cwords cword\n> +\t_get_comp_words_by_ref -n =: cur cwords cword\n\nHmm, on second thought, this will break the following case, in bash:\n\n\t. /etc/bash_completion;\t# defines _get_comp_words_by_ref\n\t. contrib/completion/git-completion.bash\n\nNot sure how to salvage that.  Maybe we need a git-specific API\nthat wraps _get_comp_words_by_ref when the latter is available.\n\n\tif type _get_comp_words_by_ref >/dev/null 2>&1; then\n\t\t_git_get_comp_words_by_ref () {\n\t\t\t_get_comp_words_by_ref \"$@\"\n\t\t\tif test \"${words+set}\"\n\t\t\tthen\n\t\t\t\tcword=\"${words[@]}\"\n\t\t\tfi\n\t\t}\n\telse\n\t\t_git_get_comp_words_by_ref () {\n\t\t\t...\n\t\t}\n\tfi\n"},{"id":"166450","messageId":"7v62q0b8e0.fsf@alter.siamese.dyndns.org","threadId":"27195","inReplyTo":"20110427013534.GA14286@elie","subject":"Re: [PATCH] git-completion: fix zsh support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-27T04:55:35Z","receivedAt":"2011-04-27T04:55:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Felipe Contreras wrote:\n>\n>> It turns out 'words' is a special variable used by zsh completion, and\n>> it has some strange behavior as we can see.\n>> \n>> Better avoid it.\n>\n> Hoorah!  I imagine this fixes a regression introduced by\n> v1.7.4-rc0~11^2~2 (bash: get --pretty=m<tab> completion to work with\n> bash v4, 2010-12-02).\n>\n>  Acked-by: Jonathan Nieder <jrnieder@gmail.com>\n\nI'd love to share the enthusiasm, but find that \"as we can see\" needs a\nmuch more clarification.\n"},{"id":"166462","messageId":"20110427064033.GB4226@elie","threadId":"27195","inReplyTo":"7v62q0b8e0.fsf@alter.siamese.dyndns.org","subject":"[RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-04-27T06:40:34Z","receivedAt":"2011-04-27T06:40:34Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The \"_get_comp_words_by_ref -n := words\" command from the\nbash_completion library reassembles a modified version of COMP_WORDS\nwith ':' and '=' no longer treated as word separators and stores it in\nthe ${words[@]} array.  Git's programmable tab completion script uses\nthis to abstract away the difference between bash v3's and bash v4's\ndefinitions of COMP_WORDS (bash v3 used shell words, while bash v4\nbreaks at separator characters); see v1.7.4-rc0~11^2~2 (bash: get\n--pretty=m<tab> completion to work with bash v4, 2010-12-02).\n\nzsh has (or rather its completion functions have) another idea about\nwhat ${words[@]} should contain: the array is prepopulated with the\nwords from the command it is completing.  For reasons that are not\nwell understood, when git-completion.bash reserves its own \"words\"\nvariable with \"local words\", the variable becomes empty and cannot be\nchanged from then on.  So the completion script neglects the arguments\nit has seen, and words complete like git subcommand names.  For\nexample, typing \"git log origi<TAB>\" gives no completions because\nthere are no \"git origi...\" commands.\n\nWork around this by using a different variable (comp_words) that is\nnot special to zsh.  So now commands that completed correctly before\nv1.7.4-rc0~11^2~2 on zsh should be able to complete correctly again.\n\nReported-by: Stefan Haller <lists@haller-berlin.de>\nSuggested-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJunio C Hamano wrote:\n\n> I'd love to share the enthusiasm, but find that \"as we can see\" needs a\n> much more clarification.\n\nSorry, I got carried away (I am happy to see someone has made some\nheadway in investigating this old bug).  How about this?\n\nThere is still a \"for unknown reasons\" in the above explanation.\n\n contrib/completion/git-completion.bash |   68 ++++++++++++++++---------------\n 1 files changed, 35 insertions(+), 33 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9150ea6..ce6b3e4 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -447,8 +447,9 @@ _get_comp_words_by_ref ()\n \t\tprev)\n \t\t\tprev=${words_[$cword_-1]}\n \t\t\t;;\n-\t\twords)\n-\t\t\twords=(\"${words_[@]}\")\n+\t\t-w)\n+\t\t\teval $2'=(\"${words_[@]}\")'\n+\t\t\tshift\n \t\t\t;;\n \t\tcword)\n \t\t\tcword=$cword_\n@@ -468,8 +469,9 @@ _get_comp_words_by_ref ()\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-w)\n+\t\t\teval $2='(\"${COMP_WORDS[@]}\")'\n+\t\t\tshift\n \t\t\t;;\n \t\tcword)\n \t\t\tcword=$COMP_CWORD\n@@ -739,12 +741,12 @@ __git_complete_revlist ()\n \n __git_complete_remote_or_refspec ()\n {\n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n-\tlocal cmd=\"${words[1]}\"\n+\tlocal cur comp_words cword\n+\t_get_comp_words_by_ref -n =: -w comp_words cur cword\n+\tlocal cmd=\"${comp_words[1]}\"\n \tlocal i c=2 remote=\"\" pfx=\"\" lhs=1 no_complete_refspec=0\n \twhile [ $c -lt $cword ]; do\n-\t\ti=\"${words[c]}\"\n+\t\ti=\"${comp_words[c]}\"\n \t\tcase \"$i\" in\n \t\t--mirror) [ \"$cmd\" = \"push\" ] && no_complete_refspec=1 ;;\n \t\t--all)\n@@ -991,10 +993,10 @@ __git_aliased_command ()\n # __git_find_on_cmdline requires 1 argument\n __git_find_on_cmdline ()\n {\n-\tlocal word subcommand c=1 words cword\n-\t_get_comp_words_by_ref -n =: words cword\n+\tlocal word subcommand c=1 comp_words cword\n+\t_get_comp_words_by_ref -n =: -w comp_words cword\n \twhile [ $c -lt $cword ]; do\n-\t\tword=\"${words[c]}\"\n+\t\tword=\"${comp_words[c]}\"\n \t\tfor subcommand in $1; do\n \t\t\tif [ \"$subcommand\" = \"$word\" ]; then\n \t\t\t\techo \"$subcommand\"\n@@ -1007,10 +1009,10 @@ __git_find_on_cmdline ()\n \n __git_has_doubledash ()\n {\n-\tlocal c=1 words cword\n-\t_get_comp_words_by_ref -n =: words cword\n+\tlocal c=1 comp_words cword\n+\t_get_comp_words_by_ref -n =: -w comp_words cword\n \twhile [ $c -lt $cword ]; do\n-\t\tif [ \"--\" = \"${words[c]}\" ]; then\n+\t\tif [ \"--\" = \"${comp_words[c]}\" ]; then\n \t\t\treturn 0\n \t\tfi\n \t\tc=$((++c))\n@@ -1135,11 +1137,11 @@ _git_bisect ()\n \n _git_branch ()\n {\n-\tlocal i c=1 only_local_ref=\"n\" has_r=\"n\" cur words cword\n+\tlocal i c=1 only_local_ref=\"n\" has_r=\"n\" cur comp_words cword\n \n-\t_get_comp_words_by_ref -n =: cur words cword\n+\t_get_comp_words_by_ref -n =: -w comp_words cur cword\n \twhile [ $c -lt $cword ]; do\n-\t\ti=\"${words[c]}\"\n+\t\ti=\"${comp_words[c]}\"\n \t\tcase \"$i\" in\n \t\t-d|-m)\tonly_local_ref=\"y\" ;;\n \t\t-r)\thas_r=\"y\" ;;\n@@ -1167,9 +1169,9 @@ _git_branch ()\n \n _git_bundle ()\n {\n-\tlocal words cword\n-\t_get_comp_words_by_ref -n =: words cword\n-\tlocal cmd=\"${words[2]}\"\n+\tlocal comp_words cword\n+\t_get_comp_words_by_ref -n =: -w comp_words cword\n+\tlocal cmd=\"${comp_words[2]}\"\n \tcase \"$cword\" in\n \t2)\n \t\t__gitcomp \"create list-heads verify unbundle\"\n@@ -1713,15 +1715,15 @@ _git_notes ()\n {\n \tlocal subcommands='add append copy edit list prune remove show'\n \tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n+\tlocal cur comp_words cword\n+\t_get_comp_words_by_ref -n =: -w comp_words cur cword\n \n \tcase \"$subcommand,$cur\" in\n \t,--*)\n \t\t__gitcomp '--ref'\n \t\t;;\n \t,*)\n-\t\tcase \"${words[cword-1]}\" in\n+\t\tcase \"${comp_words[cword-1]}\" in\n \t\t--ref)\n \t\t\t__gitcomp \"$(__git_refs)\"\n \t\t\t;;\n@@ -1749,7 +1751,7 @@ _git_notes ()\n \tprune,*)\n \t\t;;\n \t*)\n-\t\tcase \"${words[cword-1]}\" in\n+\t\tcase \"${comp_words[cword-1]}\" in\n \t\t-m|-F)\n \t\t\t;;\n \t\t*)\n@@ -1893,11 +1895,11 @@ _git_stage ()\n \n __git_config_get_set_variables ()\n {\n-\tlocal words cword\n-\t_get_comp_words_by_ref -n =: words cword\n+\tlocal comp_words cword\n+\t_get_comp_words_by_ref -n =: -w comp_words cword\n \tlocal prevword word config_file= c=$cword\n \twhile [ $c -gt 1 ]; do\n-\t\tword=\"${words[c]}\"\n+\t\tword=\"${comp_words[c]}\"\n \t\tcase \"$word\" in\n \t\t--global|--system|--file=*)\n \t\t\tconfig_file=\"$word\"\n@@ -2665,10 +2667,10 @@ _git_svn ()\n _git_tag ()\n {\n \tlocal i c=1 f=0\n-\tlocal words cword prev\n-\t_get_comp_words_by_ref -n =: words cword prev\n+\tlocal comp_words cword prev\n+\t_get_comp_words_by_ref -n =: -w comp_words cword prev\n \twhile [ $c -lt $cword ]; do\n-\t\ti=\"${words[c]}\"\n+\t\ti=\"${comp_words[c]}\"\n \t\tcase \"$i\" in\n \t\t-d|-v)\n \t\t\t__gitcomp \"$(__git_tags)\"\n@@ -2712,10 +2714,10 @@ _git ()\n \t\tsetopt KSH_TYPESET\n \tfi\n \n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n+\tlocal cur comp_words cword\n+\t_get_comp_words_by_ref -n =: -w comp_words cur cword\n \twhile [ $c -lt $cword ]; do\n-\t\ti=\"${words[c]}\"\n+\t\ti=\"${comp_words[c]}\"\n \t\tcase \"$i\" in\n \t\t--git-dir=*) __git_dir=\"${i#--git-dir=}\" ;;\n \t\t--bare)      __git_dir=\".\" ;;\n-- \n1.7.5\n"},{"id":"166472","messageId":"BANLkTinep961dg9v3TD8hZZAvTYL3_H+xg@mail.gmail.com","threadId":"27195","inReplyTo":"7v62q0b8e0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-completion: fix zsh support","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T08:20:42Z","receivedAt":"2011-04-27T08:20:42Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Apr 27, 2011 at 7:55 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n>\n>> Felipe Contreras wrote:\n>>\n>>> It turns out 'words' is a special variable used by zsh completion, and\n>>> it has some strange behavior as we can see.\n>>>\n>>> Better avoid it.\n>>\n>> Hoorah!  I imagine this fixes a regression introduced by\n>> v1.7.4-rc0~11^2~2 (bash: get --pretty=m<tab> completion to work with\n>> bash v4, 2010-12-02).\n>>\n>>  Acked-by: Jonathan Nieder <jrnieder@gmail.com>\n>\n> I'd love to share the enthusiasm, but find that \"as we can see\" needs a\n> much more clarification.\n\nJonathan already described it:\nhttp://article.gmane.org/gmane.comp.version-control.git/170665\n\nAnd this snipped demonstrates it:\n---\nset_vars ()\n{\n\tcur=\"foo\"\n\twords=\"foo\"\n\tcwords=\"foo\"\n}\n\n_foo ()\n{\n\tlocal cur words cwords\n\tset_vars\n\n\techo \"cur=${cur} words=${words} cwords=${cwords}\" >> /tmp/comp_test.txt\n}\n\ncompdef _foo foo\n---\n\nWhen trying to auto-complete 'foo' the result would be:\n  cur=foo words= cwords=foo\n\nYou can see it's special in the source code:\nhttp://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob;f=Src/Zle/complete.c;h=6398fd3e77eff2ef819c10503d316b08421034ac;hb=HEAD#l1116\n\n-- \nFelipe Contreras\n"},{"id":"166484","messageId":"BANLkTinA5hfddqpGwOBjk+2oFDpwqORrSg@mail.gmail.com","threadId":"27195","inReplyTo":"20110427064033.GB4226@elie","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T08:42:28Z","receivedAt":"2011-04-27T08:42:28Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Apr 27, 2011 at 9:40 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> I'd love to share the enthusiasm, but find that \"as we can see\" needs a\n>> much more clarification.\n>\n> Sorry, I got carried away (I am happy to see someone has made some\n> headway in investigating this old bug).  How about this?\n\nWhat's wrong with my patch?\n\n> There is still a \"for unknown reasons\" in the above explanation.\n\nI'm asking zsh guys:\nhttp://www.zsh.org/mla/workers/2011/msg00515.html\n\n-- \nFelipe Contreras\n"},{"id":"166487","messageId":"20110427091140.GB14849@elie","threadId":"27195","inReplyTo":"BANLkTinA5hfddqpGwOBjk+2oFDpwqORrSg@mail.gmail.com","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-04-27T09:11:40Z","receivedAt":"2011-04-27T09:11:40Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n> On Wed, Apr 27, 2011 at 9:40 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n>> Sorry, I got carried away (I am happy to see someone has made some\n>> headway in investigating this old bug).  How about this?\n>\n> What's wrong with my patch?\n\nAs mentioned at\nhttp://thread.gmane.org/gmane.comp.version-control.git/172142/focus=172157\nit breaks the tab completion in the common case that the user uses\nthe standard bash completion library (usually provided at\n/etc/bash_completion) and git uses its _get_comp_words_by_ref\nfunction.  You can test like so:\n\n\t% bash\n\t$ . /etc/bash_completion\n\t$ . contrib/completion/git-completion.bash\n\t$ git fetch origin <TAB>\n\nI also made a small cosmetic change which is less important (sorry, I\nshould have mentioned it before): the patch I sent spells out\ncomp_words instead of writing cwords to avoid a false analogy between\nthe array of all completion words (cwords) and the current word index\n(cword).\n\n>> There is still a \"for unknown reasons\" in the above explanation.\n>\n> I'm asking zsh guys:\n> http://www.zsh.org/mla/workers/2011/msg00515.html\n\nThanks.  It looks like to get the semantics I expect from \"local\"\nin zsh, one needs to use \"typeset -h\" (which bash does not support,\nunfortunately).  Probably it is best to steer clear of zsh's special\nvariables anyway.\n"},{"id":"166492","messageId":"BANLkTi=3T2B=Gtyk7V_3DB3V+GkbXAaqPw@mail.gmail.com","threadId":"27195","inReplyTo":"20110427091140.GB14849@elie","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T09:49:53Z","receivedAt":"2011-04-27T09:49:53Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Apr 27, 2011 at 12:11 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>> On Wed, Apr 27, 2011 at 9:40 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>\n>>> Sorry, I got carried away (I am happy to see someone has made some\n>>> headway in investigating this old bug).  How about this?\n>>\n>> What's wrong with my patch?\n>\n> As mentioned at\n> http://thread.gmane.org/gmane.comp.version-control.git/172142/focus=172157\n> it breaks the tab completion in the common case that the user uses\n> the standard bash completion library (usually provided at\n> /etc/bash_completion) and git uses its _get_comp_words_by_ref\n> function.  You can test like so:\n>\n>        % bash\n>        $ . /etc/bash_completion\n>        $ . contrib/completion/git-completion.bash\n>        $ git fetch origin <TAB>\n\nWhere does that 'bash_completion' file comes from? I don't have it on\nmy system. Do we really need to use _get_comp_words_by_ref from there?\nCan't we have our own _get_comp_words_by_ref?\n\n> I also made a small cosmetic change which is less important (sorry, I\n> should have mentioned it before): the patch I sent spells out\n> comp_words instead of writing cwords to avoid a false analogy between\n> the array of all completion words (cwords) and the current word index\n> (cword).\n\nI don't see how cword can be confused with cwords. Besides, I prefer\nuniformity, so if you use comp_words, cword should be cur_word, or\nword_index, or something like that.\n\n>>> There is still a \"for unknown reasons\" in the above explanation.\n>>\n>> I'm asking zsh guys:\n>> http://www.zsh.org/mla/workers/2011/msg00515.html\n>\n> Thanks.  It looks like to get the semantics I expect from \"local\"\n> in zsh, one needs to use \"typeset -h\" (which bash does not support,\n> unfortunately).  Probably it is best to steer clear of zsh's special\n> variables anyway.\n\nHmm, interesting, maybe we should try to find a way to replace those\n'local' with 'typeset -h'.\n\n-- \nFelipe Contreras\n"},{"id":"166494","messageId":"BANLkTim8ofv63uPutcMJpo1PAVHv7dwVRg@mail.gmail.com","threadId":"27195","inReplyTo":"BANLkTi=3T2B=Gtyk7V_3DB3V+GkbXAaqPw@mail.gmail.com","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"John Szakmeister","fromEmail":"john@szakmeister.net","sentAt":"2011-04-27T09:59:05Z","receivedAt":"2011-04-27T09:59:05Z","isPatch":true,"sender":{"key":"john@szakmeister.net","avatar":"https://avatars.githubusercontent.com/u/448087?v=4"},"body":"On Wed, Apr 27, 2011 at 5:49 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n[snip]\n> Where does that 'bash_completion' file comes from? I don't have it on\n> my system. Do we really need to use _get_comp_words_by_ref from there?\n> Can't we have our own _get_comp_words_by_ref?\n\nIt typically comes from the bash-completion package for your system.\nDepending on your distro, it may or may not be there by default.  You\ncan get the source from here though:\n   <http://bash-completion.alioth.debian.org/>\n\n/me goes back to lurking.\n\n-John\n"},{"id":"166495","messageId":"BANLkTikN7iMa_z7wRN8pUS07SMatpyoDPQ@mail.gmail.com","threadId":"27195","inReplyTo":"BANLkTi=3T2B=Gtyk7V_3DB3V+GkbXAaqPw@mail.gmail.com","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T10:09:28Z","receivedAt":"2011-04-27T10:09:28Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Apr 27, 2011 at 12:49 PM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> On Wed, Apr 27, 2011 at 12:11 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> Thanks.  It looks like to get the semantics I expect from \"local\"\n>> in zsh, one needs to use \"typeset -h\" (which bash does not support,\n>> unfortunately).  Probably it is best to steer clear of zsh's special\n>> variables anyway.\n>\n> Hmm, interesting, maybe we should try to find a way to replace those\n> 'local' with 'typeset -h'.\n\nThis seems to do it:\n\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -75,6 +75,10 @@\n\n if [[ -n ${ZSH_VERSION-} ]]; then\n        autoload -U +X bashcompinit && bashcompinit\n+\n+       # 'words' has special meaning in zsh, and only typeset -h seems to\n+       # override that\n+       alias local=\"typeset -h\"\n fi\n\n case \"$COMP_WORDBREAKS\" in\n\n-- \nFelipe Contreras\n"},{"id":"166527","messageId":"7vzknb8wgd.fsf@alter.siamese.dyndns.org","threadId":"27195","inReplyTo":"BANLkTinep961dg9v3TD8hZZAvTYL3_H+xg@mail.gmail.com","subject":"Re: [PATCH] git-completion: fix zsh support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-27T16:56:18Z","receivedAt":"2011-04-27T16:56:18Z","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> On Wed, Apr 27, 2011 at 7:55 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> ...\n>> I'd love to share the enthusiasm, but find that \"as we can see\" needs a\n>> much more clarification.\n>\n> Jonathan already described it:\n> http://article.gmane.org/gmane.comp.version-control.git/170665\n>\n> And this snipped demonstrates it:\n> ...\n\nWhen I say \"needs more clarification\" during a review, I am not asking the\ncontributor to explain it in the discussion thread to _me_ who happen to\nbe asking at that moment.  I am asking the contributor to explain it to\npeople who will read \"git log\" output 6 months down the road.\n\nYou have been here long enough to know that \"Jonathan already described\nit\" that is not connected in the commit that is going to be recorded is\nnot something we appreciate, no?\n\nIn any case, the message of Jonathan's\n\n    Subject: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability\n    Date: Wed, 27 Apr 2011 01:40:34 -0500\n    Message-ID: <20110427064033.GB4226@elie>\n\nseems to explain it better.  The naming of variables and other details\nmight need to be settled, but other than that is it correct to understand\nthat we will see a final version along the line of that patch?\n\nThanks.\n"},{"id":"166531","messageId":"BANLkTi=tsgfteYRj8iODZifZuepVCJGq1w@mail.gmail.com","threadId":"27195","inReplyTo":"7vzknb8wgd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-completion: fix zsh support","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T17:17:15Z","receivedAt":"2011-04-27T17:17:15Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Wed, Apr 27, 2011 at 7:56 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> On Wed, Apr 27, 2011 at 7:55 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> ...\n>>> I'd love to share the enthusiasm, but find that \"as we can see\" needs a\n>>> much more clarification.\n>>\n>> Jonathan already described it:\n>> http://article.gmane.org/gmane.comp.version-control.git/170665\n>>\n>> And this snipped demonstrates it:\n>> ...\n>\n> When I say \"needs more clarification\" during a review, I am not asking the\n> contributor to explain it in the discussion thread to _me_ who happen to\n> be asking at that moment.  I am asking the contributor to explain it to\n> people who will read \"git log\" output 6 months down the road.\n>\n> You have been here long enough to know that \"Jonathan already described\n> it\" that is not connected in the commit that is going to be recorded is\n> not something we appreciate, no?\n\nHow is one supposed to know when the clarification is sufficient or\nnot? Are you advocating communication through git patches?\n\nI prefer to discuss in the mailing list, and when there's consensus\nfire 'git send-email', that's what they do in lkml.\n\n> In any case, the message of Jonathan's\n>\n>    Subject: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability\n>    Date: Wed, 27 Apr 2011 01:40:34 -0500\n>    Message-ID: <20110427064033.GB4226@elie>\n>\n> seems to explain it better.  The naming of variables and other details\n> might need to be settled, but other than that is it correct to understand\n> that we will see a final version along the line of that patch?\n\nI prefer something short, and to the point:\n\n---\ngit-completion: fix zsh support\n\nSupport for zsh was broken on commit da48616f1d[1], due to the fact\nthat 'words' is a is a special variable used by zsh completion[2].\n\nJonathan Nieder found that 'typset -h' resets that special behavior,\nwhich is exactly what we want. So alias the currently used 'local' to\nthat.\n\n[1] http://article.gmane.org/gmane.comp.version-control.git/170665\n[2] http://article.gmane.org/gmane.comp.shells.zsh.devel/22484\n---\n\n-- \nFelipe Contreras\n"},{"id":"166558","messageId":"20110427212704.GB18596@elie","threadId":"27195","inReplyTo":"BANLkTikN7iMa_z7wRN8pUS07SMatpyoDPQ@mail.gmail.com","subject":"[PATCH] completion: move private shopt shim for zsh to __git_ namespace","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-04-27T21:27:04Z","receivedAt":"2011-04-27T21:27:04Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Most zsh users probably probably do not expect a custom shopt function\nto enter their environment just because they ran \"source\n~/.git-completion.sh\".\n\nSuch namespace pollution makes development of other scripts confusing\n(because it makes the bash-specific shopt utility seem to be available\nin zsh) and makes git's tab completion script brittle (since any other\nshell snippet implementing some other subset of shopt will break it).\nRename the shopt shim to the more innocuous __git_shopt to be a good\ncitizen (with two underscores to avoid confusion with completion rules\nfor a hypothetical \"git shopt\" command).\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nHi,\n\nFelipe Contreras wrote:\n\n> +++ b/contrib/completion/git-completion.bash\n> @@ -75,6 +75,10 @@\n> \n>  if [[ -n ${ZSH_VERSION-} ]]; then\n>         autoload -U +X bashcompinit && bashcompinit\n> +\n> +       # 'words' has special meaning in zsh, and only typeset -h seems to\n> +       # override that\n> +       alias local=\"typeset -h\"\n>  fi\n> \n>  case \"$COMP_WORDBREAKS\" in\n\nThe above would change the meaning of \"local\" in the user's\nenvironment and in all shell snippets she sources later.  Are you sure\nthat's intended?\n\nActually the completion script already has a problem along the same\nlines.  Thanks for a reminder.\n\n contrib/completion/git-completion.bash |   12 ++++++++----\n 1 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9150ea6..ab95690 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -629,12 +629,12 @@ __git_refs_remotes ()\n __git_remotes ()\n {\n \tlocal i ngoff IFS=$'\\n' d=\"$(__gitdir)\"\n-\tshopt -q nullglob || ngoff=1\n-\tshopt -s nullglob\n+\t__git_shopt -q nullglob || ngoff=1\n+\t__git_shopt -s nullglob\n \tfor i in \"$d/remotes\"/*; do\n \t\techo ${i#$d/remotes/}\n \tdone\n-\t[ \"$ngoff\" ] && shopt -u nullglob\n+\t[ \"$ngoff\" ] && __git_shopt -u nullglob\n \tfor i in $(git --git-dir=\"$d\" config --get-regexp 'remote\\..*\\.url' 2>/dev/null); do\n \t\ti=\"${i#remote.}\"\n \t\techo \"${i/.url*/}\"\n@@ -2800,7 +2800,7 @@ complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \\\n fi\n \n if [[ -n ${ZSH_VERSION-} ]]; then\n-\tshopt () {\n+\t__git_shopt () {\n \t\tlocal option\n \t\tif [ $# -ne 2 ]; then\n \t\t\techo \"USAGE: $0 (-q|-s|-u) <option>\" >&2\n@@ -2823,4 +2823,8 @@ if [[ -n ${ZSH_VERSION-} ]]; then\n \t\t\treturn 1\n \t\tesac\n \t}\n+else\n+\t__git_shopt () {\n+\t\tshopt \"$@\"\n+\t}\n fi\n-- \n1.7.5\n"},{"id":"166568","messageId":"BANLkTinKgubAeFy+mJ=hGdG8c-QXjyNTcA@mail.gmail.com","threadId":"27195","inReplyTo":"20110427212704.GB18596@elie","subject":"Re: [PATCH] completion: move private shopt shim for zsh to __git_ namespace","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-27T22:48:58Z","receivedAt":"2011-04-27T22:48:58Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, Apr 28, 2011 at 12:27 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -75,6 +75,10 @@\n>>\n>>  if [[ -n ${ZSH_VERSION-} ]]; then\n>>         autoload -U +X bashcompinit && bashcompinit\n>> +\n>> +       # 'words' has special meaning in zsh, and only typeset -h seems to\n>> +       # override that\n>> +       alias local=\"typeset -h\"\n>>  fi\n>>\n>>  case \"$COMP_WORDBREAKS\" in\n>\n> The above would change the meaning of \"local\" in the user's\n> environment and in all shell snippets she sources later.  Are you sure\n> that's intended?\n\nCrap. I didn't realize that :(\n\nI have been looking for a way to have local aliases or functions, but\nI can't find any.\n\n-- \nFelipe Contreras\n"},{"id":"166570","messageId":"20110427230008.GD18596@elie","threadId":"27195","inReplyTo":"BANLkTinKgubAeFy+mJ=hGdG8c-QXjyNTcA@mail.gmail.com","subject":"Re: [PATCH] completion: move private shopt shim for zsh to __git_ namespace","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-04-27T23:00:08Z","receivedAt":"2011-04-27T23:00:08Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> I have been looking for a way to have local aliases or functions, but\n> I can't find any.\n\nIt is possible to do\n\n\tif [[ -n ${ZSH_VERSION-} ]]; then\n\t\talias __git_local=\"typeset -h\"\n\telse\n\t\talias __git_local=local\n\tfi\n\nbut let's consider that for a moment.\n\n 1. It's ugly (it means completion code would use a dialect where the\n    ordinary \"local\" keyword has to be spelled differently).\n\n 2. It's ugly (use of aliases in scripts sets off alarm bells.  As\n    Almquist's sh manual says:\n\n\tAliases provide a convenient way for naïve users to create\n\tshorthands for commands without having to learn how to create\n\tfunctions with arguments.  They can also be used to create\n\tlexically obscure code.  This use is discouraged.)\n\n 3. It's fragile (maybe some day a function from zsh's completion\n    library that we call will look at $words and get utterly confused).\n\nI don't mean to sound so negative; actually I am very happy to see us\ngetting closer to a full understanding of the problem and relevant\nconstraints.\n"},{"id":"166651","messageId":"20110428160115.GA19003@goldbirke","threadId":"27195","inReplyTo":"20110427064033.GB4226@elie","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2011-04-28T16:01:15Z","receivedAt":"2011-04-28T16:01:15Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\n\nOn Wed, Apr 27, 2011 at 01:40:34AM -0500, Jonathan Nieder wrote:\n> The \"_get_comp_words_by_ref -n := words\" command from the\n> bash_completion library reassembles a modified version of COMP_WORDS\n> with ':' and '=' no longer treated as word separators and stores it in\n> the ${words[@]} array.  Git's programmable tab completion script uses\n> this to abstract away the difference between bash v3's and bash v4's\n> definitions of COMP_WORDS (bash v3 used shell words, while bash v4\n> breaks at separator characters); see v1.7.4-rc0~11^2~2 (bash: get\n> --pretty=m<tab> completion to work with bash v4, 2010-12-02).\n> \n> zsh has (or rather its completion functions have) another idea about\n> what ${words[@]} should contain: the array is prepopulated with the\n> words from the command it is completing.  For reasons that are not\n> well understood, when git-completion.bash reserves its own \"words\"\n> variable with \"local words\", the variable becomes empty and cannot be\n> changed from then on.  So the completion script neglects the arguments\n> it has seen, and words complete like git subcommand names.  For\n> example, typing \"git log origi<TAB>\" gives no completions because\n> there are no \"git origi...\" commands.\n> \n> Work around this by using a different variable (comp_words) that is\n> not special to zsh.  So now commands that completed correctly before\n> v1.7.4-rc0~11^2~2 on zsh should be able to complete correctly again.\n\nThanks for this explanation.  I tried to fix this some time ago, but\ngot only as far as to indentify that something is amiss with returning\n$words from _get_comp_words_by_ref(), and during tracing I saw so much\nweird and (for me) unexplicable zsh behavior that I simply gave up.\n\nBut this patch heavily conflicted with one of my long-forgotten\ncleanup patch series, and that series together with the above\nexplanation gave me alternative ideas for fixing this issue with zsh.\n\nSo, here it is.  The first two patches are independent cleanups, but\nthey make the actual fix in the third patch so short.\n\nIt works well as far as I tested it with both bash and zsh, but I\nwould really appreciate a few extra sets of eyeballs for the cleanups\nand sanity-checking and testing of the bugfix.\n\n\nSZEDER Gábor (3):\n  bash: don't modify the $cur variable in completion functions\n  bash: remove unnecessary _get_comp_words_by_ref() invocations\n  bash: don't declare 'local words' to make zsh happy\n\n contrib/completion/git-completion.bash |  225 +++++++++-----------------------\n 1 files changed, 64 insertions(+), 161 deletions(-)\n"},{"id":"166652","messageId":"1304006513-19392-1-git-send-email-szeder@ira.uka.de","threadId":"27195","inReplyTo":"20110428160115.GA19003@goldbirke","subject":"[PATCH 1/3] bash: don't modify the $cur variable in completion functions","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2011-04-28T16:01:51Z","receivedAt":"2011-04-28T16:01:51Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Since v1.7.4-rc0~11^2~2 (bash: get --pretty=m<tab> completion to work\nwith bash v4, 2010-12-02) we use _get_comp_words_by_ref() to access\ncompletion-related variables, and the $cur variable holds the word\ncontaining the current cursor position in all completion functions.\nThis $cur variable is left unchanged in most completion functions;\nthere are only four functions modifying its value, namely __gitcomp(),\n__git_complete_revlist_file(), __git_complete_remote_or_refspec(), and\n_git_config().\n\nIf this variable were never modified, then it would allow us a nice\noptimisation and cleanup.  Therefore, this patch assigns $cur to an\nother local variable and uses that for later modifications in those\nfour functions.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-completion.bash |  107 +++++++++++++++-----------------\n 1 files changed, 50 insertions(+), 57 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 840ae38..a594b40 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -491,10 +491,12 @@ __gitcomp ()\n {\n \tlocal cur\n \t_get_comp_words_by_ref -n =: cur\n+\tlocal cur_=\"$cur\"\n+\n \tif [ $# -gt 2 ]; then\n-\t\tcur=\"$3\"\n+\t\tcur_=\"$3\"\n \tfi\n-\tcase \"$cur\" in\n+\tcase \"$cur_\" in\n \t--*=)\n \t\tCOMPREPLY=()\n \t\t;;\n@@ -502,7 +504,7 @@ __gitcomp ()\n \t\tlocal IFS=$'\\n'\n \t\tCOMPREPLY=($(compgen -P \"${2-}\" \\\n \t\t\t-W \"$(__gitcomp_1 \"${1-}\" \"${4-}\")\" \\\n-\t\t\t-- \"$cur\"))\n+\t\t\t-- \"$cur_\"))\n \t\t;;\n \tesac\n }\n@@ -668,17 +670,18 @@ __git_complete_revlist_file ()\n {\n \tlocal pfx ls ref cur\n \t_get_comp_words_by_ref -n =: cur\n-\tcase \"$cur\" in\n+\tlocal cur_=\"$cur\"\n+\tcase \"$cur_\" in\n \t*..?*:*)\n \t\treturn\n \t\t;;\n \t?*:*)\n-\t\tref=\"${cur%%:*}\"\n-\t\tcur=\"${cur#*:}\"\n-\t\tcase \"$cur\" in\n+\t\tref=\"${cur_%%:*}\"\n+\t\tcur_=\"${cur_#*:}\"\n+\t\tcase \"$cur_\" in\n \t\t?*/*)\n-\t\t\tpfx=\"${cur%/*}\"\n-\t\t\tcur=\"${cur##*/}\"\n+\t\t\tpfx=\"${cur_%/*}\"\n+\t\t\tcur_=\"${cur_##*/}\"\n \t\t\tls=\"$ref:$pfx\"\n \t\t\tpfx=\"$pfx/\"\n \t\t\t;;\n@@ -708,17 +711,17 @@ __git_complete_revlist_file ()\n \t\t\t\t           s,$,/,\n \t\t\t\t       }\n \t\t\t\t       s/^.*\t//')\" \\\n-\t\t\t-- \"$cur\"))\n+\t\t\t-- \"$cur_\"))\n \t\t;;\n \t*...*)\n-\t\tpfx=\"${cur%...*}...\"\n-\t\tcur=\"${cur#*...}\"\n-\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur\"\n+\t\tpfx=\"${cur_%...*}...\"\n+\t\tcur_=\"${cur_#*...}\"\n+\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur_\"\n \t\t;;\n \t*..*)\n-\t\tpfx=\"${cur%..*}..\"\n-\t\tcur=\"${cur#*..}\"\n-\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur\"\n+\t\tpfx=\"${cur_%..*}..\"\n+\t\tcur_=\"${cur_#*..}\"\n+\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur_\"\n \t\t;;\n \t*)\n \t\t__gitcomp \"$(__git_refs)\"\n@@ -741,7 +744,7 @@ __git_complete_remote_or_refspec ()\n {\n \tlocal cur words cword\n \t_get_comp_words_by_ref -n =: cur words cword\n-\tlocal cmd=\"${words[1]}\"\n+\tlocal cur_=\"$cur\" cmd=\"${words[1]}\"\n \tlocal i c=2 remote=\"\" pfx=\"\" lhs=1 no_complete_refspec=0\n \twhile [ $c -lt $cword ]; do\n \t\ti=\"${words[c]}\"\n@@ -771,40 +774,40 @@ __git_complete_remote_or_refspec ()\n \t\treturn\n \tfi\n \t[ \"$remote\" = \".\" ] && remote=\n-\tcase \"$cur\" in\n+\tcase \"$cur_\" in\n \t*:*)\n \t\tcase \"$COMP_WORDBREAKS\" in\n \t\t*:*) : great ;;\n-\t\t*)   pfx=\"${cur%%:*}:\" ;;\n+\t\t*)   pfx=\"${cur_%%:*}:\" ;;\n \t\tesac\n-\t\tcur=\"${cur#*:}\"\n+\t\tcur_=\"${cur_#*:}\"\n \t\tlhs=0\n \t\t;;\n \t+*)\n \t\tpfx=\"+\"\n-\t\tcur=\"${cur#+}\"\n+\t\tcur_=\"${cur_#+}\"\n \t\t;;\n \tesac\n \tcase \"$cmd\" in\n \tfetch)\n \t\tif [ $lhs = 1 ]; then\n-\t\t\t__gitcomp \"$(__git_refs2 \"$remote\")\" \"$pfx\" \"$cur\"\n+\t\t\t__gitcomp \"$(__git_refs2 \"$remote\")\" \"$pfx\" \"$cur_\"\n \t\telse\n-\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur\"\n+\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur_\"\n \t\tfi\n \t\t;;\n \tpull)\n \t\tif [ $lhs = 1 ]; then\n-\t\t\t__gitcomp \"$(__git_refs \"$remote\")\" \"$pfx\" \"$cur\"\n+\t\t\t__gitcomp \"$(__git_refs \"$remote\")\" \"$pfx\" \"$cur_\"\n \t\telse\n-\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur\"\n+\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur_\"\n \t\tfi\n \t\t;;\n \tpush)\n \t\tif [ $lhs = 1 ]; then\n-\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur\"\n+\t\t\t__gitcomp \"$(__git_refs)\" \"$pfx\" \"$cur_\"\n \t\telse\n-\t\t\t__gitcomp \"$(__git_refs \"$remote\")\" \"$pfx\" \"$cur\"\n+\t\t\t__gitcomp \"$(__git_refs \"$remote\")\" \"$pfx\" \"$cur_\"\n \t\tfi\n \t\t;;\n \tesac\n@@ -2012,70 +2015,60 @@ _git_config ()\n \t\treturn\n \t\t;;\n \tbranch.*.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur##*.}\"\n-\t\t__gitcomp \"remote merge mergeoptions rebase\" \"$pfx\" \"$cur\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur##*.}\"\n+\t\t__gitcomp \"remote merge mergeoptions rebase\" \"$pfx\" \"$cur_\"\n \t\treturn\n \t\t;;\n \tbranch.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur#*.}\"\n-\t\t__gitcomp \"$(__git_heads)\" \"$pfx\" \"$cur\" \".\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur#*.}\"\n+\t\t__gitcomp \"$(__git_heads)\" \"$pfx\" \"$cur_\" \".\"\n \t\treturn\n \t\t;;\n \tguitool.*.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur##*.}\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur##*.}\"\n \t\t__gitcomp \"\n \t\t\targprompt cmd confirm needsfile noconsole norescan\n \t\t\tprompt revprompt revunmerged title\n-\t\t\t\" \"$pfx\" \"$cur\"\n+\t\t\t\" \"$pfx\" \"$cur_\"\n \t\treturn\n \t\t;;\n \tdifftool.*.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur##*.}\"\n-\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur##*.}\"\n+\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur_\"\n \t\treturn\n \t\t;;\n \tman.*.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur##*.}\"\n-\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur##*.}\"\n+\t\t__gitcomp \"cmd path\" \"$pfx\" \"$cur_\"\n \t\treturn\n \t\t;;\n \tmergetool.*.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur##*.}\"\n-\t\t__gitcomp \"cmd path trustExitCode\" \"$pfx\" \"$cur\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur##*.}\"\n+\t\t__gitcomp \"cmd path trustExitCode\" \"$pfx\" \"$cur_\"\n \t\treturn\n \t\t;;\n \tpager.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur#*.}\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur#*.}\"\n \t\t__git_compute_all_commands\n-\t\t__gitcomp \"$__git_all_commands\" \"$pfx\" \"$cur\"\n+\t\t__gitcomp \"$__git_all_commands\" \"$pfx\" \"$cur_\"\n \t\treturn\n \t\t;;\n \tremote.*.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur##*.}\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur##*.}\"\n \t\t__gitcomp \"\n \t\t\turl proxy fetch push mirror skipDefaultUpdate\n \t\t\treceivepack uploadpack tagopt pushurl\n-\t\t\t\" \"$pfx\" \"$cur\"\n+\t\t\t\" \"$pfx\" \"$cur_\"\n \t\treturn\n \t\t;;\n \tremote.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur#*.}\"\n-\t\t__gitcomp \"$(__git_remotes)\" \"$pfx\" \"$cur\" \".\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur#*.}\"\n+\t\t__gitcomp \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n \t\treturn\n \t\t;;\n \turl.*.*)\n-\t\tlocal pfx=\"${cur%.*}.\"\n-\t\tcur=\"${cur##*.}\"\n-\t\t__gitcomp \"insteadOf pushInsteadOf\" \"$pfx\" \"$cur\"\n+\t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur##*.}\"\n+\t\t__gitcomp \"insteadOf pushInsteadOf\" \"$pfx\" \"$cur_\"\n \t\treturn\n \t\t;;\n \tesac\n-- \n1.7.5.86.g799a6\n"},{"id":"166654","messageId":"1304006513-19392-2-git-send-email-szeder@ira.uka.de","threadId":"27195","inReplyTo":"1304006513-19392-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH 2/3] bash: remove unnecessary _get_comp_words_by_ref() invocations","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2011-04-28T16:01:52Z","receivedAt":"2011-04-28T16:01:52Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"In v1.7.4-rc0~11^2~2 (bash: get --pretty=m<tab> completion to work\nwith bash v4, 2010-12-02) we started to use _get_comp_words_by_ref()\nto access completion-related variables.  That was large change, and to\nmake it easily reviewable, we invoked _get_comp_words_by_ref() in each\ncompletion function and systematically replaced every occurance of\nbash's completion-related variables ($COMP_WORDS and $COMP_CWORD) with\nvariables set by _get_comp_words_by_ref().\n\nThis has the downside that _get_comp_words_by_ref() is invoked several\ntimes during a single completion.  The worst offender is perhaps 'git\nlog mas<TAB>': during the completion of 'master'\n_get_comp_words_by_ref() is invoked no less than six times.\n\nHowever, the variables $prev, $cword, and $words provided by\n_get_comp_words_by_ref() are not modified in any of the completion\nfunctions, and the previous commit ensures that the $cur variable is\nnot modified as well.  This makes it possible to invoke\n_get_comp_words_by_ref() to get those variables only once in our\ntoplevel completion functions _git() and _gitk(), and all other\ncompletion functions will inherit them.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-completion.bash |  116 +++-----------------------------\n 1 files changed, 11 insertions(+), 105 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex a594b40..862b840 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -489,8 +489,6 @@ fi\n # generates completion reply with compgen\n __gitcomp ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tlocal cur_=\"$cur\"\n \n \tif [ $# -gt 2 ]; then\n@@ -553,8 +551,7 @@ __git_tags ()\n __git_refs ()\n {\n \tlocal i is_hash=y dir=\"$(__gitdir \"${1-}\")\" track=\"${2-}\"\n-\tlocal cur format refs\n-\t_get_comp_words_by_ref -n =: cur\n+\tlocal format refs\n \tif [ -d \"$dir\" ]; then\n \t\tcase \"$cur\" in\n \t\trefs|refs/*)\n@@ -668,9 +665,7 @@ __git_compute_merge_strategies ()\n \n __git_complete_revlist_file ()\n {\n-\tlocal pfx ls ref cur\n-\t_get_comp_words_by_ref -n =: cur\n-\tlocal cur_=\"$cur\"\n+\tlocal pfx ls ref cur_=\"$cur\"\n \tcase \"$cur_\" in\n \t*..?*:*)\n \t\treturn\n@@ -742,8 +737,6 @@ __git_complete_revlist ()\n \n __git_complete_remote_or_refspec ()\n {\n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n \tlocal cur_=\"$cur\" cmd=\"${words[1]}\"\n \tlocal i c=2 remote=\"\" pfx=\"\" lhs=1 no_complete_refspec=0\n \twhile [ $c -lt $cword ]; do\n@@ -815,8 +808,6 @@ __git_complete_remote_or_refspec ()\n \n __git_complete_strategy ()\n {\n-\tlocal cur prev\n-\t_get_comp_words_by_ref -n =: cur prev\n \t__git_compute_merge_strategies\n \tcase \"$prev\" in\n \t-s|--strategy)\n@@ -994,8 +985,7 @@ __git_aliased_command ()\n # __git_find_on_cmdline requires 1 argument\n __git_find_on_cmdline ()\n {\n-\tlocal word subcommand c=1 words cword\n-\t_get_comp_words_by_ref -n =: words cword\n+\tlocal word subcommand c=1\n \twhile [ $c -lt $cword ]; do\n \t\tword=\"${words[c]}\"\n \t\tfor subcommand in $1; do\n@@ -1010,8 +1000,7 @@ __git_find_on_cmdline ()\n \n __git_has_doubledash ()\n {\n-\tlocal c=1 words cword\n-\t_get_comp_words_by_ref -n =: words cword\n+\tlocal c=1\n \twhile [ $c -lt $cword ]; do\n \t\tif [ \"--\" = \"${words[c]}\" ]; then\n \t\t\treturn 0\n@@ -1025,8 +1014,7 @@ __git_whitespacelist=\"nowarn warn error error-all fix\"\n \n _git_am ()\n {\n-\tlocal cur dir=\"$(__gitdir)\"\n-\t_get_comp_words_by_ref -n =: cur\n+\tlocal dir=\"$(__gitdir)\"\n \tif [ -d \"$dir\"/rebase-apply ]; then\n \t\t__gitcomp \"--skip --continue --resolved --abort\"\n \t\treturn\n@@ -1050,8 +1038,6 @@ _git_am ()\n \n _git_apply ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--whitespace=*)\n \t\t__gitcomp \"$__git_whitespacelist\" \"\" \"${cur##--whitespace=}\"\n@@ -1074,8 +1060,6 @@ _git_add ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n@@ -1089,8 +1073,6 @@ _git_add ()\n \n _git_archive ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--format=*)\n \t\t__gitcomp \"$(git archive --list)\" \"\" \"${cur##--format=}\"\n@@ -1138,9 +1120,8 @@ _git_bisect ()\n \n _git_branch ()\n {\n-\tlocal i c=1 only_local_ref=\"n\" has_r=\"n\" cur words cword\n+\tlocal i c=1 only_local_ref=\"n\" has_r=\"n\"\n \n-\t_get_comp_words_by_ref -n =: cur words cword\n \twhile [ $c -lt $cword ]; do\n \t\ti=\"${words[c]}\"\n \t\tcase \"$i\" in\n@@ -1170,8 +1151,6 @@ _git_branch ()\n \n _git_bundle ()\n {\n-\tlocal words cword\n-\t_get_comp_words_by_ref -n =: words cword\n \tlocal cmd=\"${words[2]}\"\n \tcase \"$cword\" in\n \t2)\n@@ -1194,8 +1173,6 @@ _git_checkout ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--conflict=*)\n \t\t__gitcomp \"diff3 merge\" \"\" \"${cur##--conflict=}\"\n@@ -1225,8 +1202,6 @@ _git_cherry ()\n \n _git_cherry_pick ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--edit --no-commit\"\n@@ -1241,8 +1216,6 @@ _git_clean ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--dry-run --quiet\"\n@@ -1254,8 +1227,6 @@ _git_clean ()\n \n _git_clone ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n@@ -1282,8 +1253,6 @@ _git_commit ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--cleanup=*)\n \t\t__gitcomp \"default strip verbatim whitespace\n@@ -1318,8 +1287,6 @@ _git_commit ()\n \n _git_describe ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n@@ -1351,8 +1318,6 @@ _git_diff ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--cached --staged --pickaxe-all --pickaxe-regex\n@@ -1373,8 +1338,6 @@ _git_difftool ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--tool=*)\n \t\t__gitcomp \"$__git_mergetools_common kompare\" \"\" \"${cur##--tool=}\"\n@@ -1399,8 +1362,6 @@ __git_fetch_options=\"\n \n _git_fetch ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"$__git_fetch_options\"\n@@ -1412,8 +1373,6 @@ _git_fetch ()\n \n _git_format_patch ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--thread=*)\n \t\t__gitcomp \"\n@@ -1445,8 +1404,6 @@ _git_format_patch ()\n \n _git_fsck ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n@@ -1461,8 +1418,6 @@ _git_fsck ()\n \n _git_gc ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--prune --aggressive\"\n@@ -1481,8 +1436,6 @@ _git_grep ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n@@ -1505,8 +1458,6 @@ _git_grep ()\n \n _git_help ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--all --info --man --web\"\n@@ -1524,8 +1475,6 @@ _git_help ()\n \n _git_init ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--shared=*)\n \t\t__gitcomp \"\n@@ -1545,8 +1494,6 @@ _git_ls_files ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--cached --deleted --modified --others --ignored\n@@ -1607,8 +1554,6 @@ _git_log ()\n \tif [ -f \"$g/MERGE_HEAD\" ]; then\n \t\tmerge=\"--merge\"\n \tfi\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--pretty=*)\n \t\t__gitcomp \"$__git_log_pretty_formats $(__git_pretty_aliases)\n@@ -1662,8 +1607,6 @@ _git_merge ()\n {\n \t__git_complete_strategy && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"$__git_merge_options\"\n@@ -1674,8 +1617,6 @@ _git_merge ()\n \n _git_mergetool ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--tool=*)\n \t\t__gitcomp \"$__git_mergetools_common tortoisemerge\" \"\" \"${cur##--tool=}\"\n@@ -1696,8 +1637,6 @@ _git_merge_base ()\n \n _git_mv ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--dry-run\"\n@@ -1716,8 +1655,6 @@ _git_notes ()\n {\n \tlocal subcommands='add append copy edit list prune remove show'\n \tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n \n \tcase \"$subcommand,$cur\" in\n \t,--*)\n@@ -1767,8 +1704,6 @@ _git_pull ()\n {\n \t__git_complete_strategy && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n@@ -1784,8 +1719,6 @@ _git_pull ()\n \n _git_push ()\n {\n-\tlocal cur prev\n-\t_get_comp_words_by_ref -n =: cur prev\n \tcase \"$prev\" in\n \t--repo)\n \t\t__gitcomp \"$(__git_remotes)\"\n@@ -1810,8 +1743,6 @@ _git_push ()\n _git_rebase ()\n {\n \tlocal dir=\"$(__gitdir)\"\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tif [ -d \"$dir\"/rebase-apply ] || [ -d \"$dir\"/rebase-merge ]; then\n \t\t__gitcomp \"--continue --skip --abort\"\n \t\treturn\n@@ -1853,8 +1784,6 @@ __git_send_email_suppresscc_options=\"author self cc bodycc sob cccmd body all\"\n \n _git_send_email ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--confirm=*)\n \t\t__gitcomp \"\n@@ -1896,8 +1825,6 @@ _git_stage ()\n \n __git_config_get_set_variables ()\n {\n-\tlocal words cword\n-\t_get_comp_words_by_ref -n =: words cword\n \tlocal prevword word config_file= c=$cword\n \twhile [ $c -gt 1 ]; do\n \t\tword=\"${words[c]}\"\n@@ -1928,8 +1855,6 @@ __git_config_get_set_variables ()\n \n _git_config ()\n {\n-\tlocal cur prev\n-\t_get_comp_words_by_ref -n =: cur prev\n \tcase \"$prev\" in\n \tbranch.*.remote)\n \t\t__gitcomp \"$(__git_remotes)\"\n@@ -2389,8 +2314,6 @@ _git_reset ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--merge --mixed --hard --soft --patch\"\n@@ -2402,8 +2325,6 @@ _git_reset ()\n \n _git_revert ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--edit --mainline --no-edit --no-commit --signoff\"\n@@ -2417,8 +2338,6 @@ _git_rm ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"--cached --dry-run --ignore-unmatch --quiet\"\n@@ -2432,8 +2351,6 @@ _git_shortlog ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n@@ -2451,8 +2368,6 @@ _git_show ()\n {\n \t__git_has_doubledash && return\n \n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--pretty=*)\n \t\t__gitcomp \"$__git_log_pretty_formats $(__git_pretty_aliases)\n@@ -2476,8 +2391,6 @@ _git_show ()\n \n _git_show_branch ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n@@ -2494,8 +2407,6 @@ _git_show_branch ()\n \n _git_stash ()\n {\n-\tlocal cur\n-\t_get_comp_words_by_ref -n =: cur\n \tlocal save_opts='--keep-index --no-keep-index --quiet --patch'\n \tlocal subcommands='save list show apply clear drop pop create branch'\n \tlocal subcommand=\"$(__git_find_on_cmdline \"$subcommands\")\"\n@@ -2540,8 +2451,6 @@ _git_submodule ()\n \n \tlocal subcommands=\"add status init update summary foreach sync\"\n \tif [ -z \"$(__git_find_on_cmdline \"$subcommands\")\" ]; then\n-\t\tlocal cur\n-\t\t_get_comp_words_by_ref -n =: cur\n \t\tcase \"$cur\" in\n \t\t--*)\n \t\t\t__gitcomp \"--quiet --cached\"\n@@ -2585,8 +2494,6 @@ _git_svn ()\n \t\t\t--edit --rmdir --find-copies-harder --copy-similarity=\n \t\t\t\"\n \n-\t\tlocal cur\n-\t\t_get_comp_words_by_ref -n =: cur\n \t\tcase \"$subcommand,$cur\" in\n \t\tfetch,--*)\n \t\t\t__gitcomp \"--revision= --fetch-all $fc_opts\"\n@@ -2658,8 +2565,6 @@ _git_svn ()\n _git_tag ()\n {\n \tlocal i c=1 f=0\n-\tlocal words cword prev\n-\t_get_comp_words_by_ref -n =: words cword prev\n \twhile [ $c -lt $cword ]; do\n \t\ti=\"${words[c]}\"\n \t\tcase \"$i\" in\n@@ -2705,8 +2610,8 @@ _git ()\n \t\tsetopt KSH_TYPESET\n \tfi\n \n-\tlocal cur words cword\n-\t_get_comp_words_by_ref -n =: cur words cword\n+\tlocal cur words cword prev\n+\t_get_comp_words_by_ref -n =: cur words cword prev\n \twhile [ $c -lt $cword ]; do\n \t\ti=\"${words[c]}\"\n \t\tcase \"$i\" in\n@@ -2756,15 +2661,16 @@ _gitk ()\n \t\tsetopt KSH_TYPESET\n \tfi\n \n+\tlocal cur words cword prev\n+\t_get_comp_words_by_ref -n =: cur words cword prev\n+\n \t__git_has_doubledash && return\n \n-\tlocal cur\n \tlocal g=\"$(__gitdir)\"\n \tlocal merge=\"\"\n \tif [ -f \"$g/MERGE_HEAD\" ]; then\n \t\tmerge=\"--merge\"\n \tfi\n-\t_get_comp_words_by_ref -n =: cur\n \tcase \"$cur\" in\n \t--*)\n \t\t__gitcomp \"\n-- \n1.7.5.86.g799a6\n"},{"id":"166653","messageId":"1304006513-19392-3-git-send-email-szeder@ira.uka.de","threadId":"27195","inReplyTo":"1304006513-19392-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH 3/3] bash: don't declare 'local words' to make zsh happy","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2011-04-28T16:01:53Z","receivedAt":"2011-04-28T16:01:53Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"The \"_get_comp_words_by_ref -n := words\" command from the\nbash_completion library reassembles a modified version of COMP_WORDS\nwith ':' and '=' no longer treated as word separators and stores it in\nthe ${words[@]} array.  Git's programmable tab completion script uses\nthis to abstract away the difference between bash v3's and bash v4's\ndefinitions of COMP_WORDS (bash v3 used shell words, while bash v4\nbreaks at separator characters); see v1.7.4-rc0~11^2~2 (bash: get\n--pretty=m<tab> completion to work with bash v4, 2010-12-02).\n\nzsh has (or rather its completion functions have) another idea about\nwhat ${words[@]} should contain: the array is prepopulated with the\nwords from the command it is completing.  For reasons that are not\nwell understood, when git-completion.bash reserves its own \"words\"\nvariable with \"local words\", the variable becomes empty and cannot be\nchanged from then on.  So the completion script neglects the arguments\nit has seen, and words complete like git subcommand names.  For\nexample, typing \"git log origi<TAB>\" gives no completions because\nthere are no \"git origi...\" commands.\n\nHowever, when this words variable is not declared as local but is just\npopulated by _get_comp_words_by_ref() and then read in various\ncompletion functions, then zsh seems to be happy about it and our\ncompletion script works as expected.\n\nSo, to get our completion script working again under zsh and to\nprevent the words variable from leaking into the shell environment\nunder bash, we will only declare words as local when using bash.\n\nReported-by: Stefan Haller <lists@haller-berlin.de>\nSuggested-by: Felipe Contreras <felipe.contreras@gmail.com>\nExplained-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n contrib/completion/git-completion.bash |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 862b840..6869765 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2608,9 +2608,11 @@ _git ()\n \tif [[ -n ${ZSH_VERSION-} ]]; then\n \t\temulate -L bash\n \t\tsetopt KSH_TYPESET\n+\telse\n+\t\tlocal words\n \tfi\n \n-\tlocal cur words cword prev\n+\tlocal cur cword prev\n \t_get_comp_words_by_ref -n =: cur words cword prev\n \twhile [ $c -lt $cword ]; do\n \t\ti=\"${words[c]}\"\n@@ -2659,9 +2661,11 @@ _gitk ()\n \tif [[ -n ${ZSH_VERSION-} ]]; then\n \t\temulate -L bash\n \t\tsetopt KSH_TYPESET\n+\telse\n+\t\tlocal words\n \tfi\n \n-\tlocal cur words cword prev\n+\tlocal cur cword prev\n \t_get_comp_words_by_ref -n =: cur words cword prev\n \n \t__git_has_doubledash && return\n-- \n1.7.5.86.g799a6\n"},{"id":"166684","messageId":"BANLkTikt=Em6kP93aZfuZ3DEXdXN+7sAzg@mail.gmail.com","threadId":"27195","inReplyTo":"20110428160115.GA19003@goldbirke","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-28T20:24:05Z","receivedAt":"2011-04-28T20:24:05Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2011/4/28 SZEDER Gábor <szeder@ira.uka.de>:\n> On Wed, Apr 27, 2011 at 01:40:34AM -0500, Jonathan Nieder wrote:\n>> The \"_get_comp_words_by_ref -n := words\" command from the\n>> bash_completion library reassembles a modified version of COMP_WORDS\n>> with ':' and '=' no longer treated as word separators and stores it in\n>> the ${words[@]} array.  Git's programmable tab completion script uses\n>> this to abstract away the difference between bash v3's and bash v4's\n>> definitions of COMP_WORDS (bash v3 used shell words, while bash v4\n>> breaks at separator characters); see v1.7.4-rc0~11^2~2 (bash: get\n>> --pretty=m<tab> completion to work with bash v4, 2010-12-02).\n>>\n>> zsh has (or rather its completion functions have) another idea about\n>> what ${words[@]} should contain: the array is prepopulated with the\n>> words from the command it is completing.  For reasons that are not\n>> well understood, when git-completion.bash reserves its own \"words\"\n>> variable with \"local words\", the variable becomes empty and cannot be\n>> changed from then on.  So the completion script neglects the arguments\n>> it has seen, and words complete like git subcommand names.  For\n>> example, typing \"git log origi<TAB>\" gives no completions because\n>> there are no \"git origi...\" commands.\n>>\n>> Work around this by using a different variable (comp_words) that is\n>> not special to zsh.  So now commands that completed correctly before\n>> v1.7.4-rc0~11^2~2 on zsh should be able to complete correctly again.\n>\n> Thanks for this explanation.  I tried to fix this some time ago, but\n> got only as far as to indentify that something is amiss with returning\n> $words from _get_comp_words_by_ref(), and during tracing I saw so much\n> weird and (for me) unexplicable zsh behavior that I simply gave up.\n>\n> But this patch heavily conflicted with one of my long-forgotten\n> cleanup patch series, and that series together with the above\n> explanation gave me alternative ideas for fixing this issue with zsh.\n>\n> So, here it is.  The first two patches are independent cleanups, but\n> they make the actual fix in the third patch so short.\n>\n> It works well as far as I tested it with both bash and zsh, but I\n> would really appreciate a few extra sets of eyeballs for the cleanups\n> and sanity-checking and testing of the bugfix.\n>\n>\n> SZEDER Gábor (3):\n>  bash: don't modify the $cur variable in completion functions\n>  bash: remove unnecessary _get_comp_words_by_ref() invocations\n>  bash: don't declare 'local words' to make zsh happy\n>\n>  contrib/completion/git-completion.bash |  225 +++++++++-----------------------\n>  1 files changed, 64 insertions(+), 161 deletions(-)\n\nNice! Much better approach.\n\nI also noticed that behavior when not defining 'words' as local, but\nthough modifying all those instances was overkill.\n\nAcked-by: Felipe Contreras <felipe.contreras@gmail.com>\n\n-- \nFelipe Contreras\n"},{"id":"166687","messageId":"7v4o5i3xqk.fsf@alter.siamese.dyndns.org","threadId":"27195","inReplyTo":"BANLkTikt=Em6kP93aZfuZ3DEXdXN+7sAzg@mail.gmail.com","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-28T20:52:03Z","receivedAt":"2011-04-28T20:52:03Z","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> Nice! Much better approach.\n>\n> I also noticed that behavior when not defining 'words' as local, but\n> though modifying all those instances was overkill.\n>\n> Acked-by: Felipe Contreras <felipe.contreras@gmail.com>\n\nDo you mean reviewed-by or even better tested-by?\n"},{"id":"166692","messageId":"BANLkTim9h+OrYP6rMN_aWizHiQxZJ60vdg@mail.gmail.com","threadId":"27195","inReplyTo":"7v4o5i3xqk.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] completion: avoid \"words\" as variable name for zsh portability","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-04-28T21:27:37Z","receivedAt":"2011-04-28T21:27:37Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, Apr 28, 2011 at 11:52 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> Nice! Much better approach.\n>>\n>> I also noticed that behavior when not defining 'words' as local, but\n>> though modifying all those instances was overkill.\n>>\n>> Acked-by: Felipe Contreras <felipe.contreras@gmail.com>\n>\n> Do you mean reviewed-by or even better tested-by?\n\nRight. Reviewed-by.\n\n-- \nFelipe Contreras\n"},{"id":"166953","messageId":"BANLkTimbLhkMRKLUBWhjg+oBtRwAEWGSqQ@mail.gmail.com","threadId":"27195","inReplyTo":"1304006513-19392-3-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH 3/3] bash: don't declare 'local words' to make zsh happy","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-05-03T17:53:15Z","receivedAt":"2011-05-03T17:53:15Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, Apr 28, 2011 at 7:01 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> The \"_get_comp_words_by_ref -n := words\" command from the\n> bash_completion library reassembles a modified version of COMP_WORDS\n> with ':' and '=' no longer treated as word separators and stores it in\n> the ${words[@]} array.  Git's programmable tab completion script uses\n> this to abstract away the difference between bash v3's and bash v4's\n> definitions of COMP_WORDS (bash v3 used shell words, while bash v4\n> breaks at separator characters); see v1.7.4-rc0~11^2~2 (bash: get\n> --pretty=m<tab> completion to work with bash v4, 2010-12-02).\n>\n> zsh has (or rather its completion functions have) another idea about\n> what ${words[@]} should contain: the array is prepopulated with the\n> words from the command it is completing.  For reasons that are not\n> well understood, when git-completion.bash reserves its own \"words\"\n> variable with \"local words\", the variable becomes empty and cannot be\n> changed from then on.  So the completion script neglects the arguments\n> it has seen, and words complete like git subcommand names.  For\n> example, typing \"git log origi<TAB>\" gives no completions because\n> there are no \"git origi...\" commands.\n>\n> However, when this words variable is not declared as local but is just\n> populated by _get_comp_words_by_ref() and then read in various\n> completion functions, then zsh seems to be happy about it and our\n> completion script works as expected.\n>\n> So, to get our completion script working again under zsh and to\n> prevent the words variable from leaking into the shell environment\n> under bash, we will only declare words as local when using bash.\n>\n> Reported-by: Stefan Haller <lists@haller-berlin.de>\n> Suggested-by: Felipe Contreras <felipe.contreras@gmail.com>\n> Explained-by: Jonathan Nieder <jrnieder@gmail.com>\n> Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n> ---\n>  contrib/completion/git-completion.bash |    8 ++++++--\n>  1 files changed, 6 insertions(+), 2 deletions(-)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 862b840..6869765 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2608,9 +2608,11 @@ _git ()\n>        if [[ -n ${ZSH_VERSION-} ]]; then\n>                emulate -L bash\n>                setopt KSH_TYPESET\n> +       else\n> +               local words\n>        fi\n>\n> -       local cur words cword prev\n> +       local cur cword prev\n>        _get_comp_words_by_ref -n =: cur words cword prev\n>        while [ $c -lt $cword ]; do\n>                i=\"${words[c]}\"\n> @@ -2659,9 +2661,11 @@ _gitk ()\n>        if [[ -n ${ZSH_VERSION-} ]]; then\n>                emulate -L bash\n>                setopt KSH_TYPESET\n> +       else\n> +               local words\n>        fi\n>\n> -       local cur words cword prev\n> +       local cur cword prev\n>        _get_comp_words_by_ref -n =: cur words cword prev\n>\n>        __git_has_doubledash && return\n> --\n> 1.7.5.86.g799a6\n\nHere's another option:\n\nFrom 603e4db259283a4eb6bac2315a630480e3238f50 Mon Sep 17 00:00:00 2001\nFrom: Felipe Contreras <felipe.contreras@gmail.com>\nDate: Tue, 3 May 2011 20:45:26 +0300\nSubject: [PATCH] git-completion: fix zsh support\n\nIt turns out 'words' is a special variable used by zsh completion.\n\nThere's probably a bug in zsh's bashcompinit:\nhttp://article.gmane.org/gmane.comp.shells.zsh.devel/22546\n\nBut in the meantime we can workaround it this way.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash\nb/contrib/completion/git-completion.bash\nindex 00691fc..d32b1b8 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2608,6 +2608,9 @@ _git ()\n \tif [[ -n ${ZSH_VERSION-} ]]; then\n \t\temulate -L bash\n \t\tsetopt KSH_TYPESET\n+\n+\t\t# 'words' has special meaning in zsh; override that\n+\t\ttypeset -h words\n \tfi\n\n \tlocal cur words cword prev\n-- \n1.7.5\n\n-- \nFelipe Contreras\n"},{"id":"167219","messageId":"20110506054604.GA13351@elie","threadId":"27195","inReplyTo":"20110427212704.GB18596@elie","subject":"Re: [PATCH] completion: move private shopt shim for zsh to __git_ namespace","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-05-06T05:46:04Z","receivedAt":"2011-05-06T05:46:04Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(culling cc list of quiet people :))\nJonathan Nieder wrote:\n\n> Most zsh users probably probably do not expect a custom shopt function\n> to enter their environment just because they ran \"source\n> ~/.git-completion.sh\".\n>\n> Such namespace pollution makes development of other scripts confusing\n> (because it makes the bash-specific shopt utility seem to be available\n> in zsh) and makes git's tab completion script brittle (since any other\n> shell snippet implementing some other subset of shopt will break it).\n> Rename the shopt shim to the more innocuous __git_shopt to be a good\n> citizen (with two underscores to avoid confusion with completion rules\n> for a hypothetical \"git shopt\" command).\n\nBy the way, I meant the above[1] as a genuine patch submission.\nThoughts?  Bugs?  Improvements?\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/172142/focus=172275\n"},{"id":"167232","messageId":"BANLkTimrjra=vz7MHTDWMq8Bk_2jv-D-Ng@mail.gmail.com","threadId":"27195","inReplyTo":"20110506054604.GA13351@elie","subject":"Re: [PATCH] completion: move private shopt shim for zsh to __git_ namespace","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2011-05-06T08:35:50Z","receivedAt":"2011-05-06T08:35:50Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Fri, May 6, 2011 at 8:46 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> (culling cc list of quiet people :))\n> Jonathan Nieder wrote:\n>\n>> Most zsh users probably probably do not expect a custom shopt function\n>> to enter their environment just because they ran \"source\n>> ~/.git-completion.sh\".\n>>\n>> Such namespace pollution makes development of other scripts confusing\n>> (because it makes the bash-specific shopt utility seem to be available\n>> in zsh) and makes git's tab completion script brittle (since any other\n>> shell snippet implementing some other subset of shopt will break it).\n>> Rename the shopt shim to the more innocuous __git_shopt to be a good\n>> citizen (with two underscores to avoid confusion with completion rules\n>> for a hypothetical \"git shopt\" command).\n>\n> By the way, I meant the above[1] as a genuine patch submission.\n> Thoughts?  Bugs?  Improvements?\n\nLooks fine to me.\n\n-- \nFelipe Contreras\n"},{"id":"167360","messageId":"20110508104815.GF1377@goldbirke","threadId":"27195","inReplyTo":"20110506054604.GA13351@elie","subject":"Re: [PATCH] completion: move private shopt shim for zsh to __git_ namespace","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2011-05-08T10:48:15Z","receivedAt":"2011-05-08T10:48:15Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, May 06, 2011 at 12:46:04AM -0500, Jonathan Nieder wrote:\n> (culling cc list of quiet people :))\n> Jonathan Nieder wrote:\n> \n> > Most zsh users probably probably do not expect a custom shopt function\n> > to enter their environment just because they ran \"source\n> > ~/.git-completion.sh\".\n> >\n> > Such namespace pollution makes development of other scripts confusing\n> > (because it makes the bash-specific shopt utility seem to be available\n> > in zsh) and makes git's tab completion script brittle (since any other\n> > shell snippet implementing some other subset of shopt will break it).\n> > Rename the shopt shim to the more innocuous __git_shopt to be a good\n> > citizen (with two underscores to avoid confusion with completion rules\n> > for a hypothetical \"git shopt\" command).\n> \n> By the way, I meant the above[1] as a genuine patch submission.\n> Thoughts?  Bugs?  Improvements?\n> \n> [1] http://thread.gmane.org/gmane.comp.version-control.git/172142/focus=172275\n\nIt surely won't be fun to debug such breakages, so:\n\nAcked-by: SZEDER Gábor <szeder@ira.uka.de>\n"}]}