{"thread":{"id":"30230","subject":"[PATCH v2 1/4] completion: simplify __gitcomp_1","startedAt":"2012-04-12T23:49:59Z","lastAt":"2012-04-14T07:21:52Z","messageCount":12,"participants":["Felipe Contreras","Jonathan Nieder","Andreas Schwab"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"189164","messageId":"1334274603-3277-1-git-send-email-felipe.contreras@gmail.com","threadId":"30230","inReplyTo":null,"subject":"[PATCH v2 0/4] completion: trivial cleanups and fixes","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-12T23:49:59Z","receivedAt":"2012-04-12T23:49:59Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nJust a few simpliciations, improvements, and add some missing options.\n\nThis series depends on the bash completion tests patch.\n\nFelipe Contreras (4):\n  completion: simplify __gitcomp_1\n  completion: trivial simplification\n  completion: add missing general options\n  completion: improve 'git --exec-path' completion\n\n contrib/completion/git-completion.bash |   16 +++++++++-------\n t/t9902-completion.sh                  |   18 +++++++++++++++++-\n 2 files changed, 26 insertions(+), 8 deletions(-)\n\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189163","messageId":"1334274603-3277-2-git-send-email-felipe.contreras@gmail.com","threadId":"30230","inReplyTo":"1334274603-3277-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 1/4] completion: simplify __gitcomp_1","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-12T23:50:00Z","receivedAt":"2012-04-12T23:50:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 31f714d..13be9a7 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -307,13 +307,13 @@ __git_ps1 ()\n # __gitcomp_1 requires 2 arguments\n __gitcomp_1 ()\n {\n-\tlocal c IFS=' '$'\\t'$'\\n'\n+\tlocal c s IFS=' '$'\\t'$'\\n'\n \tfor c in $1; do\n \t\tcase \"$c$2\" in\n-\t\t--*=*) printf %s$'\\n' \"$c$2\" ;;\n-\t\t*.)    printf %s$'\\n' \"$c$2\" ;;\n-\t\t*)     printf %s$'\\n' \"$c$2 \" ;;\n+\t\t--*=* | *.) s=\"\" ;;\n+\t\t*)          s=\" \" ;;\n \t\tesac\n+\t\techo \"$c$2$s\"\n \tdone\n }\n \n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189165","messageId":"1334274603-3277-3-git-send-email-felipe.contreras@gmail.com","threadId":"30230","inReplyTo":"1334274603-3277-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 2/4] completion: trivial simplification","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-12T23:50:01Z","receivedAt":"2012-04-12T23:50:01Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"cword-1 is the previous word ($prev).\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 13be9a7..9d36bb7 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1658,7 +1658,7 @@ _git_notes ()\n \t\t__gitcomp '--ref'\n \t\t;;\n \t,*)\n-\t\tcase \"${words[cword-1]}\" in\n+\t\tcase \"$prev\" in\n \t\t--ref)\n \t\t\t__gitcomp_nl \"$(__git_refs)\"\n \t\t\t;;\n@@ -1684,7 +1684,7 @@ _git_notes ()\n \tprune,*)\n \t\t;;\n \t*)\n-\t\tcase \"${words[cword-1]}\" in\n+\t\tcase \"$prev\" in\n \t\t-m|-F)\n \t\t\t;;\n \t\t*)\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189166","messageId":"1334274603-3277-4-git-send-email-felipe.contreras@gmail.com","threadId":"30230","inReplyTo":"1334274603-3277-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 3/4] completion: add missing general options","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-12T23:50:02Z","receivedAt":"2012-04-12T23:50:02Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"And add relevant tests.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    2 ++\n t/t9902-completion.sh                  |   16 ++++++++++++++++\n 2 files changed, 18 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 9d36bb7..6a8cf9f 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2640,8 +2640,10 @@ _git ()\n \t\t\t--version\n \t\t\t--exec-path\n \t\t\t--html-path\n+\t\t\t--info-path\n \t\t\t--work-tree=\n \t\t\t--namespace=\n+\t\t\t--no-replace-objects\n \t\t\t--help\n \t\t\t\"\n \t\t\t;;\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 3bbec79..f2075af 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -92,8 +92,10 @@ test_expect_success 'double dash \"git\" itself' '\n \t--version Z\n \t--exec-path Z\n \t--html-path Z\n+\t--info-path Z\n \t--work-tree=\n \t--namespace=\n+\t--no-replace-objects Z\n \t--help Z\n \tEOF\n \ttest_completion \"git --\"\n@@ -114,4 +116,18 @@ test_expect_success 'double dash \"git checkout\"' '\n \ttest_completion \"git checkout --\"\n '\n \n+test_expect_success 'general options' '\n+\ttest_completion \"git --ver\" \"--version \" &&\n+\ttest_completion \"git --hel\" \"--help \" &&\n+\ttest_completion \"git --exe\" \"--exec-path \" &&\n+\ttest_completion \"git --htm\" \"--html-path \" &&\n+\ttest_completion \"git --pag\" \"--paginate \" &&\n+\ttest_completion \"git --no-p\" \"--no-pager \" &&\n+\ttest_completion \"git --git\" \"--git-dir=\" &&\n+\ttest_completion \"git --wor\" \"--work-tree=\" &&\n+\ttest_completion \"git --nam\" \"--namespace=\" &&\n+\ttest_completion \"git --bar\" \"--bare \" &&\n+\ttest_completion \"git --inf\" \"--info-path \" &&\n+\ttest_completion \"git --no-r\" \"--no-replace-objects \"\n+'\n test_done\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189167","messageId":"1334274603-3277-5-git-send-email-felipe.contreras@gmail.com","threadId":"30230","inReplyTo":"1334274603-3277-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 4/4] completion: improve 'git --exec-path' completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-12T23:50:03Z","receivedAt":"2012-04-12T23:50:03Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"All other options that accept an argument are completed this way, plus,\nthe '--foo bar' format doesn't seem to work correctly at the moment.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/completion/git-completion.bash |    2 +-\n t/t9902-completion.sh                  |    4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6a8cf9f..efed24a 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2638,7 +2638,7 @@ _git ()\n \t\t\t--git-dir=\n \t\t\t--bare\n \t\t\t--version\n-\t\t\t--exec-path\n+\t\t\t--exec-path=\n \t\t\t--html-path\n \t\t\t--info-path\n \t\t\t--work-tree=\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex f2075af..fd2ed3e 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -90,7 +90,7 @@ test_expect_success 'double dash \"git\" itself' '\n \t--git-dir=\n \t--bare Z\n \t--version Z\n-\t--exec-path Z\n+\t--exec-path=\n \t--html-path Z\n \t--info-path Z\n \t--work-tree=\n@@ -119,7 +119,7 @@ test_expect_success 'double dash \"git checkout\"' '\n test_expect_success 'general options' '\n \ttest_completion \"git --ver\" \"--version \" &&\n \ttest_completion \"git --hel\" \"--help \" &&\n-\ttest_completion \"git --exe\" \"--exec-path \" &&\n+\ttest_completion \"git --exe\" \"--exec-path=\" &&\n \ttest_completion \"git --htm\" \"--html-path \" &&\n \ttest_completion \"git --pag\" \"--paginate \" &&\n \ttest_completion \"git --no-p\" \"--no-pager \" &&\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189172","messageId":"20120413060845.GA15610@burratino","threadId":"30230","inReplyTo":"1334274603-3277-5-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 4/4] completion: improve 'git --exec-path' completion","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-13T06:08:45Z","receivedAt":"2012-04-13T06:08:45Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> All other options that accept an argument are completed this way, plus,\n> the '--foo bar' format doesn't seem to work correctly at the moment.\n[...]\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2638,7 +2638,7 @@ _git ()\n>  \t\t\t--git-dir=\n>  \t\t\t--bare\n>  \t\t\t--version\n> -\t\t\t--exec-path\n> +\t\t\t--exec-path=\n>  \t\t\t--html-path\n\nThanks.\n\n\"git --exec-path\" means to print the name of the directory where git\nstores its subcommands and other helpers.  I have no thoughts either\nway about whether a user typing\n\n\tgit --exec-p<TAB>\n\nis more likely to be asking for the current exec-path or intending to\noverride it.\n\nHope that helps,\nJonathan\n"},{"id":"189200","messageId":"20120413180436.GA2387@burratino","threadId":"30230","inReplyTo":"20120413060845.GA15610@burratino","subject":"Re: [PATCH v2 4/4] completion: improve 'git --exec-path' completion","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-13T18:04:36Z","receivedAt":"2012-04-13T18:04:36Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"On Fri, Apr 13, 2012 at 01:08:45AM -0500, Jonathan Nieder wrote:\n> Felipe Contreras wrote:\n\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -2638,7 +2638,7 @@ _git ()\n>>  \t\t\t--git-dir=\n>>  \t\t\t--bare\n>>  \t\t\t--version\n>> -\t\t\t--exec-path\n>> +\t\t\t--exec-path=\n[...]\n> Thanks.\n>\n> \"git --exec-path\" means to print the name of the directory where git\n> stores its subcommands and other helpers.  I have no thoughts either\n> way about whether a user typing\n>\n> \tgit --exec-p<TAB>\n>\n> is more likely to be asking for the current exec-path or intending to\n> override it.\n\nIn other words, how about something like this?  Tests left as an exercise\nto the interested reader.\n\n-- >8 --\nSubject: completion: do not add trailing space when completing --exec-path\n\n--exec-path looks like to the completion script like an unambiguous\nsuccessful completion script, but it is wrong.  The user could be\ntrying to do\n\n\tgit --exec-path; # print name of helper directory\n\nor\n\n\tgit --exec-path=/path/to/alternative/helper/dir <subcommand>\n\nso the most helpful thing to do is to leave out the trailing space and\nleave it to the operator to type an equal sign or carriage return\naccording to the situation.\n\nReported-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n contrib/completion/git-completion.bash |   14 ++++++++------\n 1 file changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 31f714da..ecbf2172 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -307,12 +307,14 @@ __git_ps1 ()\n # __gitcomp_1 requires 2 arguments\n __gitcomp_1 ()\n {\n-\tlocal c IFS=' '$'\\t'$'\\n'\n+\tlocal c word IFS=' '$'\\t'$'\\n'\n \tfor c in $1; do\n-\t\tcase \"$c$2\" in\n-\t\t--*=*) printf %s$'\\n' \"$c$2\" ;;\n-\t\t*.)    printf %s$'\\n' \"$c$2\" ;;\n-\t\t*)     printf %s$'\\n' \"$c$2 \" ;;\n+\t\tword=$c$2\n+\t\tcase $word in\n+\t\t--*=*) printf %s$'\\n' \"$word\" ;;\n+\t\t*.)    printf %s$'\\n' \"$word\" ;;\n+\t\t*\\$)   printf %s$'\\n' \"${word%\\$}\" ;;\n+\t\t*)     printf %s$'\\n' \"$word \" ;;\n \t\tesac\n \tdone\n }\n@@ -2638,7 +2640,7 @@ _git ()\n \t\t\t--git-dir=\n \t\t\t--bare\n \t\t\t--version\n-\t\t\t--exec-path\n+\t\t\t--exec-path\\$\n \t\t\t--html-path\n \t\t\t--work-tree=\n \t\t\t--namespace=\n-- \n1.7.10\n"},{"id":"189201","messageId":"20120413183048.GB2387@burratino","threadId":"30230","inReplyTo":"20120413180436.GA2387@burratino","subject":"Re: [PATCH v2 4/4] completion: improve 'git --exec-path' completion","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-13T18:30:49Z","receivedAt":"2012-04-13T18:30:49Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jonathan Nieder wrote:\n\n> In other words, how about something like this?  Tests left as an exercise\n> to the interested reader.\n\n... and here's a simpler way to spell it.\n\n-- >8 --\nSubject: completion: do not add trailing space when completing --exec-path\n\n--exec-path looks like to the completion script like an unambiguous\nsuccessful completion, but it is wrong.  The user could be trying to\ndo\n\n\tgit --exec-path; # print name of helper directory\n\nor\n\n\tgit --exec-path=/path/to/alternative/helper/dir <subcommand>\n\nso the most helpful thing to do is to leave out the trailing space and\nleave it to the operator to type an equal sign or carriage return\naccording to the situation.\n\nReported-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n contrib/completion/git-completion.bash |    1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 31f714da..d2109897 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2639,6 +2639,7 @@ _git ()\n \t\t\t--bare\n \t\t\t--version\n \t\t\t--exec-path\n+\t\t\t--exec-path=\n \t\t\t--html-path\n \t\t\t--work-tree=\n \t\t\t--namespace=\n-- \n1.7.10\n"},{"id":"189228","messageId":"CAMP44s0R7imiem4uoBggkjjJ4z5+MXVYUroe_23JE8McMCk2sQ@mail.gmail.com","threadId":"30230","inReplyTo":"20120413183048.GB2387@burratino","subject":"Re: [PATCH v2 4/4] completion: improve 'git --exec-path' completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-13T23:35:04Z","receivedAt":"2012-04-13T23:35:04Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Fri, Apr 13, 2012 at 9:30 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Jonathan Nieder wrote:\n>\n>> In other words, how about something like this?  Tests left as an exercise\n>> to the interested reader.\n>\n> ... and here's a simpler way to spell it.\n>\n> -- >8 --\n> Subject: completion: do not add trailing space when completing --exec-path\n>\n> --exec-path looks like to the completion script like an unambiguous\n> successful completion, but it is wrong.  The user could be trying to\n> do\n>\n>        git --exec-path; # print name of helper directory\n>\n> or\n>\n>        git --exec-path=/path/to/alternative/helper/dir <subcommand>\n>\n> so the most helpful thing to do is to leave out the trailing space and\n> leave it to the operator to type an equal sign or carriage return\n> according to the situation.\n>\n> Reported-by: Felipe Contreras <felipe.contreras@gmail.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n>  contrib/completion/git-completion.bash |    1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 31f714da..d2109897 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2639,6 +2639,7 @@ _git ()\n>                        --bare\n>                        --version\n>                        --exec-path\n> +                       --exec-path=\n>                        --html-path\n>                        --work-tree=\n>                        --namespace=\n> --\n> 1.7.10\n\nI don't understand, the commit message doesn't match what the patch\nactually does. In fact, this is the exact patch I sent, is it not?\n\n-- \nFelipe Contreras\n"},{"id":"189229","messageId":"20120413233706.GD13995@burratino","threadId":"30230","inReplyTo":"CAMP44s0R7imiem4uoBggkjjJ4z5+MXVYUroe_23JE8McMCk2sQ@mail.gmail.com","subject":"Re: [PATCH v2 4/4] completion: improve 'git --exec-path' completion","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-04-13T23:37:06Z","receivedAt":"2012-04-13T23:37:06Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Felipe Contreras wrote:\n\n> I don't understand, the commit message doesn't match what the patch\n> actually does.\n\nTry it, I guess?  At least for me,\n\n\tgit --exec-p<TAB>\n\ncompletes to\n\n\tgit --exec-path <cursor here>\n\nbefore the patch, and to\n\n\tgit --exec-path<cursor here>\n\nafter the patch.  Which is different from your original patch.\n\nCheers,\nJonathan\n"},{"id":"189230","messageId":"CAMP44s1C8HS2bo-dZOQKcFES8gt3=KK0h7c8uUJCeFX22ihLRg@mail.gmail.com","threadId":"30230","inReplyTo":"20120413233706.GD13995@burratino","subject":"Re: [PATCH v2 4/4] completion: improve 'git --exec-path' completion","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-13T23:43:00Z","receivedAt":"2012-04-13T23:43:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sat, Apr 14, 2012 at 2:37 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Felipe Contreras wrote:\n>\n>> I don't understand, the commit message doesn't match what the patch\n>> actually does.\n>\n> Try it, I guess?  At least for me,\n>\n>        git --exec-p<TAB>\n>\n> completes to\n>\n>        git --exec-path <cursor here>\n>\n> before the patch, and to\n>\n>        git --exec-path<cursor here>\n>\n> after the patch.  Which is different from your original patch.\n\nAh, it doesn't remove the current line, it just adds a new one. I'm\nnot sure how the completion results show up, but I guess it's better\nthan the alternatives.\n\n-- \nFelipe Contreras\n"},{"id":"189243","messageId":"m2aa2eeq27.fsf@linux-m68k.org","threadId":"30230","inReplyTo":"20120413183048.GB2387@burratino","subject":"Re: [PATCH v2 4/4] completion: improve 'git --exec-path' completion","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-04-14T07:21:52Z","receivedAt":"2012-04-14T07:21:52Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> --exec-path looks like to the completion script like an unambiguous\n\ns/like (.*like)/\\1/\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"}]}