{"thread":{"id":"35600","subject":"[PATCH v2 0/4] Fix branch.autosetup(merge|rebase) completion","startedAt":"2014-01-03T08:00:27Z","lastAt":"2014-01-05T10:08:27Z","messageCount":8,"participants":["Ramkumar Ramachandra","brian m. carlson","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"232609","messageId":"1388736031-6068-1-git-send-email-artagnon@gmail.com","threadId":"35600","inReplyTo":null,"subject":"[PATCH v2 0/4] Fix branch.autosetup(merge|rebase) completion","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2014-01-03T08:00:27Z","receivedAt":"2014-01-03T08:00:27Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nIn this iteration, I've removed hunks to prevent completing:\n\n  $ git config remote.pushdefault.<TAB>\n  $ git config branch.autosetupmerge.<TAB>\n  $ git config branch.autosetuprebase.<TAB>\n\nSince they're perfectly valid remote/ branch names.\n\nThanks.\n\nRamkumar Ramachandra (4):\n  completion: prioritize ./git-completion.bash\n  completion: introduce __gitcomp_2 ()\n  completion: fix branch.autosetup(merge|rebase)\n  completion: fix remote.pushdefault\n\n contrib/completion/git-completion.bash | 36 ++++++++++++++++++++++++++++++++--\n contrib/completion/git-completion.zsh  | 12 +++++++++++-\n 2 files changed, 45 insertions(+), 3 deletions(-)\n\n-- \n1.8.5.2.227.g53f3478\n"},{"id":"232610","messageId":"1388736031-6068-2-git-send-email-artagnon@gmail.com","threadId":"35600","inReplyTo":"1388736031-6068-1-git-send-email-artagnon@gmail.com","subject":"[PATCH v2 1/4] completion: prioritize ./git-completion.bash","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2014-01-03T08:00:28Z","receivedAt":"2014-01-03T08:00:28Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"To ease development, prioritize ./git-completion.bash over other\nstandard system paths.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n contrib/completion/git-completion.zsh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex fac5e71..6fca145 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -30,10 +30,10 @@ if [ -z \"$script\" ]; then\n \tlocal -a locations\n \tlocal e\n \tlocations=(\n+\t\t$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash\n \t\t'/etc/bash_completion.d/git' # fedora, old debian\n \t\t'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian\n \t\t'/usr/share/bash-completion/git' # gentoo\n-\t\t$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash\n \t\t)\n \tfor e in $locations; do\n \t\ttest -f $e && script=\"$e\" && break\n-- \n1.8.5.2.227.g53f3478\n"},{"id":"232612","messageId":"1388736031-6068-3-git-send-email-artagnon@gmail.com","threadId":"35600","inReplyTo":"1388736031-6068-1-git-send-email-artagnon@gmail.com","subject":"[PATCH v2 2/4] completion: introduce __gitcomp_2 ()","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2014-01-03T08:00:29Z","receivedAt":"2014-01-03T08:00:29Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"There are situations where two classes of completions possible. For\nexample\n\n  branch.<TAB>\n\nshould try to complete\n\n  branch.master.\n  branch.autosetupmerge\n  branch.autosetuprebase\n\nThe first candidate has the suffix \".\", and the second/ third candidates\nhave the suffix \" \". To facilitate completions of this kind, create a\nvariation of __gitcomp_nl () that accepts two sets of arguments and two\nindependent suffixes.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n contrib/completion/git-completion.bash | 30 ++++++++++++++++++++++++++++++\n contrib/completion/git-completion.zsh  | 10 ++++++++++\n 2 files changed, 40 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 51c2dd4..64b20b8 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -233,6 +233,36 @@ __gitcomp_nl ()\n \t__gitcompadd \"$1\" \"${2-}\" \"${3-$cur}\" \"${4- }\"\n }\n \n+# Generates completion reply from two sets of completion words, with\n+# configurable suffixes for each.\n+#\n+# It accepts 2 to 6 arguments:\n+# 1: First set of possible completion words.\n+# 2: Second set of possible completion words.\n+# 3: A prefix to be added to each completion word (both $1 and $2)\n+#    (optional).\n+# 4: Generate possible completion matches for this word (optional).\n+# 5: A suffix to be appended to each completion word in the first set\n+#    ($1) instead of the default space (optional).\n+# 6: A suffix to be appended to each completion word in the second set\n+#    ($2) instead of the default space (optional).\n+__gitcomp_2 ()\n+{\n+\tlocal pfx=\"${3-}\" cur_=\"${4-$cur}\" sfx=\"${5- }\" sfx2=\"${6- }\" i=0\n+\tlocal IFS=$' \\t\\n'\n+\n+\tfor x in $1; do\n+\t\tif [[ \"$x\" == \"$cur_\"* ]]; then\n+\t\t\tCOMPREPLY[i++]=\"$pfx$x$sfx\"\n+\t\tfi\n+\tdone\n+\tfor x in $2; do\n+\t\tif [[ \"$x\" == \"$cur_\"* ]]; then\n+\t\t\tCOMPREPLY[i++]=\"$pfx$x$sfx2\"\n+\t\tfi\n+\tdone\n+}\n+\n # Generates completion reply with compgen from newline-separated possible\n # completion filenames.\n # It accepts 1 to 3 arguments:\ndiff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\nindex 6fca145..261a7f5 100644\n--- a/contrib/completion/git-completion.zsh\n+++ b/contrib/completion/git-completion.zsh\n@@ -76,6 +76,16 @@ __gitcomp_nl ()\n \tcompadd -Q -S \"${4- }\" -p \"${2-}\" -- ${=1} && _ret=0\n }\n \n+__gitcomp_2 ()\n+{\n+\temulate -L zsh\n+\n+\tlocal IFS=$' \\t\\n'\n+\tcompset -P '*[=:]'\n+\tcompadd -Q -S \"${5- }\" -p \"${3-}\" -- ${=1} && _ret=0\n+\tcompadd -Q -S \"${6- }\" -p \"${3-}\" -- ${=2} && _ret=0\n+}\n+\n __gitcomp_file ()\n {\n \temulate -L zsh\n-- \n1.8.5.2.227.g53f3478\n"},{"id":"232611","messageId":"1388736031-6068-4-git-send-email-artagnon@gmail.com","threadId":"35600","inReplyTo":"1388736031-6068-1-git-send-email-artagnon@gmail.com","subject":"[PATCH v2 3/4] completion: fix branch.autosetup(merge|rebase)","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2014-01-03T08:00:30Z","receivedAt":"2014-01-03T08:00:30Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"When attempting to complete\n\n  $ git config branch.auto<TAB>\n\n'autosetupmerge' and 'autosetuprebase' don't come up. This is because\n\"$cur\" is matched with \"branch.*\" and a list of branches are\ncompleted. Add 'autosetup(merge|rebase)' to the list of branches using\n__gitcomp_2 ().\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n contrib/completion/git-completion.bash | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 64b20b8..cbb4eca 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1856,7 +1856,9 @@ _git_config ()\n \t\t;;\n \tbranch.*)\n \t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur#*.}\"\n-\t\t__gitcomp_nl \"$(__git_heads)\" \"$pfx\" \"$cur_\" \".\"\n+\t\t__gitcomp_2 \"$(__git_heads)\" \"\n+\t\t\tautosetupmerge autosetuprebase\n+\t\t\t\" \"$pfx\" \"$cur_\" \".\"\n \t\treturn\n \t\t;;\n \tguitool.*.*)\n-- \n1.8.5.2.227.g53f3478\n"},{"id":"232613","messageId":"1388736031-6068-5-git-send-email-artagnon@gmail.com","threadId":"35600","inReplyTo":"1388736031-6068-1-git-send-email-artagnon@gmail.com","subject":"[PATCH v2 4/4] completion: fix remote.pushdefault","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2014-01-03T08:00:31Z","receivedAt":"2014-01-03T08:00:31Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"When attempting to complete\n\n  $ git config remote.push<TAB>\n\n'pushdefault' doesn't come up. This is because \"$cur\" is matched with\n\"remote.*\" and a list of remotes are completed. Add 'pushdefault' to the\nlist of remotes using __gitcomp_2 ().\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n contrib/completion/git-completion.bash | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex cbb4eca..04d72a1 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1900,7 +1900,7 @@ _git_config ()\n \t\t;;\n \tremote.*)\n \t\tlocal pfx=\"${cur%.*}.\" cur_=\"${cur#*.}\"\n-\t\t__gitcomp_nl \"$(__git_remotes)\" \"$pfx\" \"$cur_\" \".\"\n+\t\t__gitcomp_2 \"$(__git_remotes)\" \"pushdefault\" \"$pfx\" \"$cur_\" \".\"\n \t\treturn\n \t\t;;\n \turl.*.*)\n-- \n1.8.5.2.227.g53f3478\n"},{"id":"232642","messageId":"20140103225541.GG3338@vauxhall.crustytoothpaste.net","threadId":"35600","inReplyTo":"1388736031-6068-2-git-send-email-artagnon@gmail.com","subject":"Re: [PATCH v2 1/4] completion: prioritize ./git-completion.bash","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2014-01-03T22:55:41Z","receivedAt":"2014-01-03T22:55:41Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Fri, Jan 03, 2014 at 01:30:28PM +0530, Ramkumar Ramachandra wrote:\n> To ease development, prioritize ./git-completion.bash over other\n> standard system paths.\n> \n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n>  contrib/completion/git-completion.zsh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\n> index fac5e71..6fca145 100644\n> --- a/contrib/completion/git-completion.zsh\n> +++ b/contrib/completion/git-completion.zsh\n> @@ -30,10 +30,10 @@ if [ -z \"$script\" ]; then\n>  \tlocal -a locations\n>  \tlocal e\n>  \tlocations=(\n> +\t\t$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash\n>  \t\t'/etc/bash_completion.d/git' # fedora, old debian\n>  \t\t'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian\n>  \t\t'/usr/share/bash-completion/git' # gentoo\n> -\t\t$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash\n>  \t\t)\n>  \tfor e in $locations; do\n>  \t\ttest -f $e && script=\"$e\" && break\n\nI'm not clear on this change.  It looks like this loads\ngit-completion.bash from the same directory as git-completion.zsh.  Is\nthis correct?  Your commit message says \"./\", and if that's the case, it\nhas the same security problems as putting \".\" first in your PATH.\n\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\n+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187\n"},{"id":"232643","messageId":"xmqqtxdkllcr.fsf@gitster.dls.corp.google.com","threadId":"35600","inReplyTo":"20140103225541.GG3338@vauxhall.crustytoothpaste.net","subject":"Re: [PATCH v2 1/4] completion: prioritize ./git-completion.bash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-01-03T23:03:00Z","receivedAt":"2014-01-03T23:03:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> On Fri, Jan 03, 2014 at 01:30:28PM +0530, Ramkumar Ramachandra wrote:\n>> To ease development, prioritize ./git-completion.bash over other\n>> standard system paths.\n>> \n>> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n>> ---\n>>  contrib/completion/git-completion.zsh | 2 +-\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>> \n>> diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh\n>> index fac5e71..6fca145 100644\n>> --- a/contrib/completion/git-completion.zsh\n>> +++ b/contrib/completion/git-completion.zsh\n>> @@ -30,10 +30,10 @@ if [ -z \"$script\" ]; then\n>>  \tlocal -a locations\n>>  \tlocal e\n>>  \tlocations=(\n>> +\t\t$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash\n>>  \t\t'/etc/bash_completion.d/git' # fedora, old debian\n>>  \t\t'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian\n>>  \t\t'/usr/share/bash-completion/git' # gentoo\n>> -\t\t$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash\n>>  \t\t)\n>>  \tfor e in $locations; do\n>>  \t\ttest -f $e && script=\"$e\" && break\n>\n> I'm not clear on this change.  It looks like this loads\n> git-completion.bash from the same directory as git-completion.zsh.  Is\n> this correct?\n\nI think the idea is to help those who have installed a closer to\nbleeding-edge version of completion scripts --- they will not be\nreading their zsh completions from the system default locations,\nand the place next to it would be a place more likely to have the\nmatching bleeding-edge version of bash completion than the system\ndefault place.\n\n> Your commit message says \"./\", and if that's the case, it\n> has the same security problems as putting \".\" first in your PATH.\n\nA correct observation. I think\n\n\tSubject: zsh completion: find matching custom bash completion\n\n\tIf zsh completion is being read from a location that is\n\tdifferent from system-wide default, it is likely that the\n\tuser is trying to use a custom version, perhaps closer to\n\tthe bleeding edge, installed in her own directory. We will\n\tmore likely to find the matching bash completion script in\n\tthe same directory than in those system default places.\n\nwould probably a lot closer to what the patch really does.\n"},{"id":"232662","messageId":"CALkWK0nt_EJ_Ajy1Tp9P_Z-Vj_03ZTETBcDTJBiCptKfa2qyLw@mail.gmail.com","threadId":"35600","inReplyTo":"20140103225541.GG3338@vauxhall.crustytoothpaste.net","subject":"Re: [PATCH v2 1/4] completion: prioritize ./git-completion.bash","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2014-01-05T10:08:27Z","receivedAt":"2014-01-05T10:08:27Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"brian m. carlson wrote:\n> I'm not clear on this change.  It looks like this loads\n> git-completion.bash from the same directory as git-completion.zsh.  Is\n> this correct?\n\nYes, and that's what I meant to convey with the \"./\". Junio's message\nis clearer though, so I'll use that.\n\nThanks.\n"}]}