{"thread":{"id":"31894","subject":"[PATCH v6 0/3] completion: refactor and zsh wrapper","startedAt":"2012-10-22T01:45:39Z","lastAt":"2012-10-31T14:15:20Z","messageCount":8,"participants":["Felipe Contreras","SZEDER Gábor"],"isPatch":true,"patchVersion":6,"patchTotal":3},"messages":[{"id":"201676","messageId":"1350870342-22653-1-git-send-email-felipe.contreras@gmail.com","threadId":"31894","inReplyTo":null,"subject":"[PATCH v6 0/3] completion: refactor and zsh wrapper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-10-22T01:45:39Z","receivedAt":"2012-10-22T01:45:39Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nHere's a bit of reorganition. I'm introducing a new __gitcompadd helper that is\nuseful to wrapp all changes to COMPREPLY, but first, lets get rid of\nunnecessary assignments as SZEDER suggested.\n\nThe zsh wrapper is now very very simple.\n\nSince v5:\n \n * Get rid of unnecessary COMPREPLY assignments\n\nFelipe Contreras (3):\n  completion: get rid of empty COMPREPLY assignments\n  completion: add new __gitcompadd helper\n  completion: add new zsh completion\n\n contrib/completion/git-completion.bash | 41 ++++++-----------------------\n contrib/completion/git-completion.zsh  | 48 ++++++++++++++++++++++++++++++++++\n 2 files changed, 56 insertions(+), 33 deletions(-)\n create mode 100644 contrib/completion/git-completion.zsh\n\n-- \n1.8.0\n"},{"id":"201677","messageId":"1350870342-22653-2-git-send-email-felipe.contreras@gmail.com","threadId":"31894","inReplyTo":"1350870342-22653-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 1/3] completion: get rid of empty COMPREPLY assignments","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-10-22T01:45:40Z","receivedAt":"2012-10-22T01:45:40Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"There's no functional reason for those, the only purpose they are\nsupposed to serve is to say \"we don't provide any words here\", but even\nfor that it's not used consitently.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 28 ----------------------------\n 1 file changed, 28 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex be800e0..7bdd6a8 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -238,7 +238,6 @@ __gitcomp ()\n \n \tcase \"$cur_\" in\n \t--*=)\n-\t\tCOMPREPLY=()\n \t\t;;\n \t*)\n \t\tlocal IFS=$'\\n'\n@@ -486,7 +485,6 @@ __git_complete_remote_or_refspec ()\n \t\t\tcase \"$cmd\" in\n \t\t\tpush) no_complete_refspec=1 ;;\n \t\t\tfetch)\n-\t\t\t\tCOMPREPLY=()\n \t\t\t\treturn\n \t\t\t\t;;\n \t\t\t*) ;;\n@@ -502,7 +500,6 @@ __git_complete_remote_or_refspec ()\n \t\treturn\n \tfi\n \tif [ $no_complete_refspec = 1 ]; then\n-\t\tCOMPREPLY=()\n \t\treturn\n \tfi\n \t[ \"$remote\" = \".\" ] && remote=\n@@ -776,7 +773,6 @@ _git_am ()\n \t\t\t\"\n \t\treturn\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_apply ()\n@@ -796,7 +792,6 @@ _git_apply ()\n \t\t\t\"\n \t\treturn\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_add ()\n@@ -811,7 +806,6 @@ _git_add ()\n \t\t\t\"\n \t\treturn\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_archive ()\n@@ -856,7 +850,6 @@ _git_bisect ()\n \t\t__gitcomp_nl \"$(__git_refs)\"\n \t\t;;\n \t*)\n-\t\tCOMPREPLY=()\n \t\t;;\n \tesac\n }\n@@ -969,7 +962,6 @@ _git_clean ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_clone ()\n@@ -993,7 +985,6 @@ _git_clone ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_commit ()\n@@ -1027,7 +1018,6 @@ _git_commit ()\n \t\t\t\"\n \t\treturn\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_describe ()\n@@ -1158,7 +1148,6 @@ _git_fsck ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_gc ()\n@@ -1169,7 +1158,6 @@ _git_gc ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_gitk ()\n@@ -1246,7 +1234,6 @@ _git_init ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_ls_files ()\n@@ -1265,7 +1252,6 @@ _git_ls_files ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_ls_remote ()\n@@ -1381,7 +1367,6 @@ _git_mergetool ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_merge_base ()\n@@ -1397,7 +1382,6 @@ _git_mv ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_name_rev ()\n@@ -1567,7 +1551,6 @@ _git_send_email ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_stage ()\n@@ -1680,7 +1663,6 @@ _git_config ()\n \t\treturn\n \t\t;;\n \t*.*)\n-\t\tCOMPREPLY=()\n \t\treturn\n \t\t;;\n \tesac\n@@ -2060,7 +2042,6 @@ _git_remote ()\n \t\t__gitcomp \"$c\"\n \t\t;;\n \t*)\n-\t\tCOMPREPLY=()\n \t\t;;\n \tesac\n }\n@@ -2104,7 +2085,6 @@ _git_rm ()\n \t\treturn\n \t\t;;\n \tesac\n-\tCOMPREPLY=()\n }\n \n _git_shortlog ()\n@@ -2173,8 +2153,6 @@ _git_stash ()\n \t\t*)\n \t\t\tif [ -z \"$(__git_find_on_cmdline \"$save_opts\")\" ]; then\n \t\t\t\t__gitcomp \"$subcommands\"\n-\t\t\telse\n-\t\t\t\tCOMPREPLY=()\n \t\t\tfi\n \t\t\t;;\n \t\tesac\n@@ -2187,14 +2165,12 @@ _git_stash ()\n \t\t\t__gitcomp \"--index --quiet\"\n \t\t\t;;\n \t\tshow,--*|drop,--*|branch,--*)\n-\t\t\tCOMPREPLY=()\n \t\t\t;;\n \t\tshow,*|apply,*|drop,*|pop,*|branch,*)\n \t\t\t__gitcomp_nl \"$(git --git-dir=\"$(__gitdir)\" stash list \\\n \t\t\t\t\t| sed -n -e 's/:.*//p')\"\n \t\t\t;;\n \t\t*)\n-\t\t\tCOMPREPLY=()\n \t\t\t;;\n \t\tesac\n \tfi\n@@ -2311,7 +2287,6 @@ _git_svn ()\n \t\t\t__gitcomp \"--revision= --parent\"\n \t\t\t;;\n \t\t*)\n-\t\t\tCOMPREPLY=()\n \t\t\t;;\n \t\tesac\n \tfi\n@@ -2336,13 +2311,10 @@ _git_tag ()\n \n \tcase \"$prev\" in\n \t-m|-F)\n-\t\tCOMPREPLY=()\n \t\t;;\n \t-*|tag)\n \t\tif [ $f = 1 ]; then\n \t\t\t__gitcomp_nl \"$(__git_tags)\"\n-\t\telse\n-\t\t\tCOMPREPLY=()\n \t\tfi\n \t\t;;\n \t*)\n-- \n1.8.0\n"},{"id":"201678","messageId":"1350870342-22653-3-git-send-email-felipe.contreras@gmail.com","threadId":"31894","inReplyTo":"1350870342-22653-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 2/3] completion: add new __gitcompadd helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-10-22T01:45:41Z","receivedAt":"2012-10-22T01:45:41Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The idea is to never touch the COMPREPLY variable directly.\n\nThis allows other completion systems override __gitcompadd, and do\nsomething different instead.\n\nAlso, this allows the simplification of the completion tests (separate\npatch).\n\nThere should be no functional changes.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash | 13 ++++++++-----\n 1 file changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7bdd6a8..975ae13 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -225,6 +225,11 @@ _get_comp_words_by_ref ()\n fi\n fi\n \n+__gitcompadd ()\n+{\n+\tCOMPREPLY=($(compgen -W \"$1\" -P \"$2\" -S \"$4\" -- \"$3\"))\n+}\n+\n # Generates completion reply with compgen, appending a space to possible\n # completion words, if necessary.\n # It accepts 1 to 4 arguments:\n@@ -241,9 +246,7 @@ __gitcomp ()\n \t\t;;\n \t*)\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__gitcompadd \"$(__gitcomp_1 \"${1-}\" \"${4-}\")\" \"${2-}\" \"$cur_\" \"\"\n \t\t;;\n \tesac\n }\n@@ -260,7 +263,7 @@ __gitcomp ()\n __gitcomp_nl ()\n {\n \tlocal IFS=$'\\n'\n-\tCOMPREPLY=($(compgen -P \"${2-}\" -S \"${4- }\" -W \"$1\" -- \"${3-$cur}\"))\n+\t__gitcompadd \"$1\" \"${2-}\" \"${3-$cur}\" \"${4- }\"\n }\n \n __git_heads ()\n@@ -1603,7 +1606,7 @@ _git_config ()\n \t\tlocal remote=\"${prev#remote.}\"\n \t\tremote=\"${remote%.fetch}\"\n \t\tif [ -z \"$cur\" ]; then\n-\t\t\tCOMPREPLY=(\"refs/heads/\")\n+\t\t\t__gitcompadd \"refs/heads/\"\n \t\t\treturn\n \t\tfi\n \t\t__gitcomp_nl \"$(__git_refs_remotes \"$remote\")\"\n-- \n1.8.0\n"},{"id":"201679","messageId":"1350870342-22653-4-git-send-email-felipe.contreras@gmail.com","threadId":"31894","inReplyTo":"1350870342-22653-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v6 3/3] completion: add new zsh completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-10-22T01:45:42Z","receivedAt":"2012-10-22T01:45:42Z","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 and most of the fixes are already\nin the latest version of zsh, but still, there are issues.\n\nThere is no point in going through all that pain; the emulation is easy\nto achieve, and this patch works better than zsh's emulation.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n\nv5:\n\n * Even more simplification by using __gitcompadd\n\nv4:\n\n * Simplification updates for the latest bash completion\n\nv3:\n\n * Simplification\n * Avoid COMPREPLY; call compadd directly\n * Fix _get_comp_words_by_ref\n\n contrib/completion/git-completion.zsh | 48 +++++++++++++++++++++++++++++++++++\n 1 file changed, 48 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..ae9c532\n--- /dev/null\n+++ b/contrib/completion/git-completion.zsh\n@@ -0,0 +1,48 @@\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+__gitcompadd ()\n+{\n+\tcompadd -Q -S \"$4\" -P \"${(M)cur#*[=:]}\" -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":"202206","messageId":"CAMP44s1swF2COvt6miVOWpZ7h1Av3GUgAT5ei1XXuGELXtFvCw@mail.gmail.com","threadId":"31894","inReplyTo":"1350870342-22653-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v6 0/3] completion: refactor and zsh wrapper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-10-30T16:15:34Z","receivedAt":"2012-10-30T16:15:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nOn Mon, Oct 22, 2012 at 3:45 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> Here's a bit of reorganition. I'm introducing a new __gitcompadd helper that is\n> useful to wrapp all changes to COMPREPLY, but first, lets get rid of\n> unnecessary assignments as SZEDER suggested.\n>\n> The zsh wrapper is now very very simple.\n\nJunio, Jeff, just to let you know, this is an updated version of the\nnew zsh wrapper patch series with the feedback from SZEDER. I see the\nold version is in pu, and hasn't been updated.\n\nCheers.\n\n> Since v5:\n>\n>  * Get rid of unnecessary COMPREPLY assignments\n>\n> Felipe Contreras (3):\n>   completion: get rid of empty COMPREPLY assignments\n>   completion: add new __gitcompadd helper\n>   completion: add new zsh completion\n\n-- \nFelipe Contreras\n"},{"id":"202265","messageId":"20121030225839.GO12052@goldbirke","threadId":"31894","inReplyTo":"1350870342-22653-3-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v6 2/3] completion: add new __gitcompadd helper","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-10-30T22:58:39Z","receivedAt":"2012-10-30T22:58:39Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Mon, Oct 22, 2012 at 03:45:41AM +0200, Felipe Contreras wrote:\n> The idea is to never touch the COMPREPLY variable directly.\n> \n> This allows other completion systems override __gitcompadd, and do\n> something different instead.\n> \n> Also, this allows the simplification of the completion tests (separate\n> patch).\n\nThis doesn't apply anymore, does it?  The mentioned simplification is\ndone in the other series.\n"},{"id":"202267","messageId":"CAMP44s0dctpjobNNRTOFcX4ir+nzenTZMNWFbEvBa-QU93psbA@mail.gmail.com","threadId":"31894","inReplyTo":"20121030225839.GO12052@goldbirke","subject":"Re: [PATCH v6 2/3] completion: add new __gitcompadd helper","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-10-30T23:05:34Z","receivedAt":"2012-10-30T23:05:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Oct 30, 2012 at 11:58 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> On Mon, Oct 22, 2012 at 03:45:41AM +0200, Felipe Contreras wrote:\n>> The idea is to never touch the COMPREPLY variable directly.\n>>\n>> This allows other completion systems override __gitcompadd, and do\n>> something different instead.\n>>\n>> Also, this allows the simplification of the completion tests (separate\n>> patch).\n>\n> This doesn't apply anymore, does it?  The mentioned simplification is\n> done in the other series.\n\nYeah, but you mentioned you didn't like all the COMPREPLY=() changes\nand it might be time to get rid of them.\n\nSo this series supersedes that one.\n\n-- \nFelipe Contreras\n"},{"id":"202314","messageId":"20121031141520.GB26072@goldbirke","threadId":"31894","inReplyTo":"CAMP44s0dctpjobNNRTOFcX4ir+nzenTZMNWFbEvBa-QU93psbA@mail.gmail.com","subject":"Re: [PATCH v6 2/3] completion: add new __gitcompadd helper","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-10-31T14:15:20Z","receivedAt":"2012-10-31T14:15:20Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Wed, Oct 31, 2012 at 12:05:34AM +0100, Felipe Contreras wrote:\n> On Tue, Oct 30, 2012 at 11:58 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:\n> > On Mon, Oct 22, 2012 at 03:45:41AM +0200, Felipe Contreras wrote:\n> >> The idea is to never touch the COMPREPLY variable directly.\n> >>\n> >> This allows other completion systems override __gitcompadd, and do\n> >> something different instead.\n> >>\n> >> Also, this allows the simplification of the completion tests (separate\n> >> patch).\n> >\n> > This doesn't apply anymore, does it?  The mentioned simplification is\n> > done in the other series.\n> \n> Yeah, but you mentioned you didn't like all the COMPREPLY=() changes\n> and it might be time to get rid of them.\n> \n> So this series supersedes that one.\n\nCOMPREPLY=() has nothing to do with it.  My point is that there is no\n\"separate patch\" that performs the alleged simplification made\npossible by this patch, therefore that sentence should have been\nremoved from the log message for the resubmission.\n"}]}