{"thread":{"id":"30219","subject":"[PATCH v2] tests: add initial bash completion tests","startedAt":"2012-04-11T21:57:03Z","lastAt":"2012-04-17T10:27:15Z","messageCount":21,"participants":["Felipe Contreras","Junio C Hamano","SZEDER Gábor","Thomas Rast"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"189049","messageId":"1334181423-4391-1-git-send-email-felipe.contreras@gmail.com","threadId":"30219","inReplyTo":null,"subject":"[PATCH v2] tests: add initial bash completion tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-11T21:57:03Z","receivedAt":"2012-04-11T21:57:03Z","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\nSince v1:\n\n * Check if we are running bash in posix mode\n * Don't check for all git porcelain commands\n\n t/t9902-completion.sh |  115 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 115 insertions(+)\n create mode 100755 t/t9902-completion.sh\n\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nnew file mode 100755\nindex 0000000..cbda6b5\n--- /dev/null\n+++ b/t/t9902-completion.sh\n@@ -0,0 +1,115 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2012 Felipe Contreras\n+#\n+\n+if test -n \"$BASH\" && test -z \"$POSIXLY_CORRECT\"; then\n+\t# we are in full-on bash mode\n+\ttrue\n+elif type bash >/dev/null 2>&1; then\n+\t# execute in full-on bash mode\n+\tunset POSIXLY_CORRECT\n+\texec bash \"$0\" \"$@\"\n+else\n+\techo '1..0 #SKIP skipping bash completion tests; bash not available'\n+\texit 0\n+fi\n+\n+test_description='test bash completion'\n+\n+. ./test-lib.sh\n+\n+complete ()\n+{\n+\t# do nothing\n+\treturn 0\n+}\n+\n+. \"$GIT_BUILD_DIR/contrib/completion/git-completion.bash\"\n+\n+_get_comp_words_by_ref ()\n+{\n+\twhile [ $# -gt 0 ]; do\n+\t\tcase \"$1\" in\n+\t\tcur)\n+\t\t\tcur=${_words[_cword]}\n+\t\t\t;;\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\t;;\n+\t\tcword)\n+\t\t\tcword=$_cword\n+\t\t\t;;\n+\t\tesac\n+\t\tshift\n+\tdone\n+}\n+\n+print_comp ()\n+{\n+\tlocal IFS=$'\\n'\n+\techo \"${COMPREPLY[*]}\" > out\n+}\n+\n+run_completion ()\n+{\n+\tlocal -a COMPREPLY _words\n+\tlocal _cword\n+\t_words=( $1 )\n+\t(( _cword = ${#_words[@]} - 1 ))\n+\t_git && print_comp\n+}\n+\n+test_completion ()\n+{\n+\ttest $# -gt 1 && echo \"$2\" > expected\n+\trun_completion \"$@\" &&\n+\ttest_cmp expected out\n+}\n+\n+test_expect_success 'basic' '\n+\trun_completion \"git \\\"\\\"\" &&\n+\t# built-in\n+\tgrep -q \"^add \\$\" out &&\n+\t# script\n+\tgrep -q \"^filter-branch \\$\" out &&\n+\t# plumbing\n+\t! grep -q \"^ls-files \\$\" out\n+\n+\trun_completion \"git f\" &&\n+\t! grep -q -v \"^f\" out\n+'\n+\n+test_expect_success 'double dash' '\n+\tcat >expected <<-\\EOF &&\n+\t--paginate \n+\t--no-pager \n+\t--git-dir=\n+\t--bare \n+\t--version \n+\t--exec-path \n+\t--html-path \n+\t--work-tree=\n+\t--namespace=\n+\t--help \n+\tEOF\n+\ttest_completion \"git --\"\n+\n+\tcat >expected <<-\\EOF &&\n+\t--quiet \n+\t--ours \n+\t--theirs \n+\t--track \n+\t--no-track \n+\t--merge \n+\t--conflict=\n+\t--orphan \n+\t--patch \n+\tEOF\n+\ttest_completion \"git checkout --\"\n+'\n+\n+test_done\n-- \n1.7.10.1.g1f19b8.dirty\n"},{"id":"189062","messageId":"7v8vi1j0d1.fsf@alter.siamese.dyndns.org","threadId":"30219","inReplyTo":"1334181423-4391-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-11T23:48:58Z","receivedAt":"2012-04-11T23:48:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The trailing whitespaces are not visible when reviewing tests, so I'll\nsquash this in, but otherwise looks good.\n\nThanks.\n\n t/t9902-completion.sh |   34 +++++++++++++++++-----------------\n 1 file changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex cbda6b5..51227ac 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -84,30 +84,30 @@ test_expect_success 'basic' '\n '\n \n test_expect_success 'double dash' '\n-\tcat >expected <<-\\EOF &&\n-\t--paginate \n-\t--no-pager \n+\tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n+\t--paginate Z\n+\t--no-pager Z\n \t--git-dir=\n-\t--bare \n-\t--version \n-\t--exec-path \n-\t--html-path \n+\t--bare Z\n+\t--version Z\n+\t--exec-path Z\n+\t--html-path Z\n \t--work-tree=\n \t--namespace=\n-\t--help \n+\t--help Z\n \tEOF\n \ttest_completion \"git --\"\n \n-\tcat >expected <<-\\EOF &&\n-\t--quiet \n-\t--ours \n-\t--theirs \n-\t--track \n-\t--no-track \n-\t--merge \n+\tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n+\t--quiet Z\n+\t--ours Z\n+\t--theirs Z\n+\t--track Z\n+\t--no-track Z\n+\t--merge Z\n \t--conflict=\n-\t--orphan \n-\t--patch \n+\t--orphan Z\n+\t--patch Z\n \tEOF\n \ttest_completion \"git checkout --\"\n '\n"},{"id":"189118","messageId":"CAMP44s2Ug91_sQ-XR3ck2k+x+eQRt9PNRRBOUnkrnNRhY6fEpw@mail.gmail.com","threadId":"30219","inReplyTo":"1334181423-4391-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-12T16:15:40Z","receivedAt":"2012-04-12T16:15:40Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, Apr 12, 2012 at 12:57 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n\n> +test_expect_success 'double dash' '\n> +       cat >expected <<-\\EOF &&\n> +       --paginate\n> +       --no-pager\n> +       --git-dir=\n> +       --bare\n> +       --version\n> +       --exec-path\n> +       --html-path\n> +       --work-tree=\n> +       --namespace=\n> +       --help\n> +       EOF\n> +       test_completion \"git --\"\n\nThere's a mistake here ^.\n\n--- b/t/t9902-completion.sh\n+++ a/t/t9902-completion.sh\n@@ -96,7 +96,7 @@ test_expect_success 'double dash' '\n        --namespace=\n        --help Z\n        EOF\n-       test_completion \"git --\"\n+       test_completion \"git --\" &&\n\n        sed -e \"s/Z$//\" >expected <<-\\EOF &&\n        --quiet Z\n\n-- \nFelipe Contreras\n"},{"id":"189123","messageId":"7vmx6g6e2i.fsf@alter.siamese.dyndns.org","threadId":"30219","inReplyTo":"CAMP44s2Ug91_sQ-XR3ck2k+x+eQRt9PNRRBOUnkrnNRhY6fEpw@mail.gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-12T17:43:33Z","receivedAt":"2012-04-12T17:43:33Z","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 Thu, Apr 12, 2012 at 12:57 AM, Felipe Contreras\n> <felipe.contreras@gmail.com> wrote:\n>\n>> +test_expect_success 'double dash' '\n>> +       cat >expected <<-\\EOF &&\n>> +       --paginate\n>> +       --no-pager\n>> +       --git-dir=\n>> +       --bare\n>> +       --version\n>> +       --exec-path\n>> +       --html-path\n>> +       --work-tree=\n>> +       --namespace=\n>> +       --help\n>> +       EOF\n>> +       test_completion \"git --\"\n>\n> There's a mistake here ^.\n\nYeah, good eyes!  ... ah, wait, it is your bug ;-)\n\nThanks.\n\nI wonder if it may make more sense to have this as two separate tests,\nthough...\n\n> --- b/t/t9902-completion.sh\n> +++ a/t/t9902-completion.sh\n> @@ -96,7 +96,7 @@ test_expect_success 'double dash' '\n>         --namespace=\n>         --help Z\n>         EOF\n> -       test_completion \"git --\"\n> +       test_completion \"git --\" &&\n>\n>         sed -e \"s/Z$//\" >expected <<-\\EOF &&\n>         --quiet Z\n"},{"id":"189160","messageId":"CAMP44s37znvnw+n3NsFj+ZVuxwPhrordJA0ko0LV9udPS+i3aQ@mail.gmail.com","threadId":"30219","inReplyTo":"7vmx6g6e2i.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-12T23:18:45Z","receivedAt":"2012-04-12T23:18:45Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Thu, Apr 12, 2012 at 8:43 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> On Thu, Apr 12, 2012 at 12:57 AM, Felipe Contreras\n>> <felipe.contreras@gmail.com> wrote:\n>>\n>>> +test_expect_success 'double dash' '\n>>> +       cat >expected <<-\\EOF &&\n>>> +       --paginate\n>>> +       --no-pager\n>>> +       --git-dir=\n>>> +       --bare\n>>> +       --version\n>>> +       --exec-path\n>>> +       --html-path\n>>> +       --work-tree=\n>>> +       --namespace=\n>>> +       --help\n>>> +       EOF\n>>> +       test_completion \"git --\"\n>>\n>> There's a mistake here ^.\n>\n> Yeah, good eyes!  ... ah, wait, it is your bug ;-)\n\nNot my eyes, further tests =/\n\nDo I need to resend the patch?\n\n-- \nFelipe Contreras\n"},{"id":"189161","messageId":"7vzkag3528.fsf@alter.siamese.dyndns.org","threadId":"30219","inReplyTo":"CAMP44s37znvnw+n3NsFj+ZVuxwPhrordJA0ko0LV9udPS+i3aQ@mail.gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-12T23:26:23Z","receivedAt":"2012-04-12T23:26:23Z","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 Thu, Apr 12, 2012 at 8:43 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>>\n>>> On Thu, Apr 12, 2012 at 12:57 AM, Felipe Contreras\n>>> <felipe.contreras@gmail.com> wrote:\n>>>\n>>>> +test_expect_success 'double dash' '\n>>>> +       cat >expected <<-\\EOF &&\n>>>> +       --paginate\n>>>> +       --no-pager\n>>>> +       --git-dir=\n>>>> +       --bare\n>>>> +       --version\n>>>> +       --exec-path\n>>>> +       --html-path\n>>>> +       --work-tree=\n>>>> +       --namespace=\n>>>> +       --help\n>>>> +       EOF\n>>>> +       test_completion \"git --\"\n>>>\n>>> There's a mistake here ^.\n>>\n>> Yeah, good eyes!  ... ah, wait, it is your bug ;-)\n>\n> Not my eyes, further tests =/\n>\n> Do I need to resend the patch?\n\nNot necessarily.  If you can eyeball what is queued on 'pu' and gave me an\nAck (or send a replacement with \"You stupid, you amended it wrong!\") that\nshould be sufficient.\n\nThanks.\n"},{"id":"189178","messageId":"20120413091236.GC2164@goldbirke","threadId":"30219","inReplyTo":"1334181423-4391-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-13T09:12:36Z","receivedAt":"2012-04-13T09:12:36Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\n\nOn Thu, Apr 12, 2012 at 12:57:03AM +0300, Felipe Contreras wrote:\n> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n> ---\n> \n> Since v1:\n> \n>  * Check if we are running bash in posix mode\n>  * Don't check for all git porcelain commands\n> \n>  t/t9902-completion.sh |  115 +++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 115 insertions(+)\n>  create mode 100755 t/t9902-completion.sh\n> \n> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\n> new file mode 100755\n> index 0000000..cbda6b5\n> --- /dev/null\n> +++ b/t/t9902-completion.sh\n> @@ -0,0 +1,115 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2012 Felipe Contreras\n> +#\n> +\n> +if test -n \"$BASH\" && test -z \"$POSIXLY_CORRECT\"; then\n> +\t# we are in full-on bash mode\n> +\ttrue\n> +elif type bash >/dev/null 2>&1; then\n> +\t# execute in full-on bash mode\n> +\tunset POSIXLY_CORRECT\n> +\texec bash \"$0\" \"$@\"\n> +else\n> +\techo '1..0 #SKIP skipping bash completion tests; bash not available'\n> +\texit 0\n> +fi\n> +\n> +test_description='test bash completion'\n> +\n> +. ./test-lib.sh\n> +\n> +complete ()\n> +{\n> +\t# do nothing\n> +\treturn 0\n> +}\n> +\n> +. \"$GIT_BUILD_DIR/contrib/completion/git-completion.bash\"\n> +\n> +_get_comp_words_by_ref ()\n> +{\n> +\twhile [ $# -gt 0 ]; do\n> +\t\tcase \"$1\" in\n> +\t\tcur)\n> +\t\t\tcur=${_words[_cword]}\n> +\t\t\t;;\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\t;;\n> +\t\tcword)\n> +\t\t\tcword=$_cword\n> +\t\t\t;;\n> +\t\tesac\n> +\t\tshift\n> +\tdone\n> +}\n\nGit's completion script already implements this function.  Why\noverride it here?\n\n> +print_comp ()\n> +{\n> +\tlocal IFS=$'\\n'\n> +\techo \"${COMPREPLY[*]}\" > out\n> +}\n> +\n> +run_completion ()\n> +{\n> +\tlocal -a COMPREPLY _words\n> +\tlocal _cword\n> +\t_words=( $1 )\n> +\t(( _cword = ${#_words[@]} - 1 ))\n> +\t_git && print_comp\n> +}\n> +\n> +test_completion ()\n> +{\n> +\ttest $# -gt 1 && echo \"$2\" > expected\n> +\trun_completion \"$@\" &&\n> +\ttest_cmp expected out\n> +}\n> +\n> +test_expect_success 'basic' '\n> +\trun_completion \"git \\\"\\\"\" &&\n> +\t# built-in\n> +\tgrep -q \"^add \\$\" out &&\n> +\t# script\n> +\tgrep -q \"^filter-branch \\$\" out &&\n> +\t# plumbing\n> +\t! grep -q \"^ls-files \\$\" out\n\nThe && is missing here at the end of the line.\n\n> +\trun_completion \"git f\" &&\n> +\t! grep -q -v \"^f\" out\n\ngrep is not a git command, so I'm not sure, but shouldn't these use\n'test_must_fail grep' instead of '! grep'?\n\n\nAnyway, thanks for pushing this forward.  I have a bunch of tests for\nmy __git_ps1() optimizations, but, being a bash function, I could\nnever figure out how to integrate it with the test framework.\n\n\nBest,\nGábor\n"},{"id":"189179","messageId":"20120413094500.GD2164@goldbirke","threadId":"30219","inReplyTo":"20120413091236.GC2164@goldbirke","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-13T09:45:00Z","receivedAt":"2012-04-13T09:45:00Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Apr 13, 2012 at 11:12:36AM +0200, SZEDER Gábor wrote:\n> On Thu, Apr 12, 2012 at 12:57:03AM +0300, Felipe Contreras wrote:\n> > +. \"$GIT_BUILD_DIR/contrib/completion/git-completion.bash\"\n> > +\n> > +_get_comp_words_by_ref ()\n> > +{\n> > +\twhile [ $# -gt 0 ]; do\n> > +\t\tcase \"$1\" in\n> > +\t\tcur)\n> > +\t\t\tcur=${_words[_cword]}\n> > +\t\t\t;;\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\t;;\n> > +\t\tcword)\n> > +\t\t\tcword=$_cword\n> > +\t\t\t;;\n> > +\t\tesac\n> > +\t\tshift\n> > +\tdone\n> > +}\n> \n> Git's completion script already implements this function.  Why\n> override it here?\n\nAh, ok, I think I got it.\n\nOf course, the words on the command line must be specified somehow to\ntest completion functions.  But the two implementations of\n_get_comp_words_by_ref() for bash and zsh in the completion script\ntake the words on the command line from different variables, so we\nneed a common implementation to test completion functions both on bash\nand zsh.  Hence the _get_comp_words_by_ref() above, which takes the\nwords on the command line and their count from $_words and $_cword,\nrespectively, and run_completion() below, which fills those variables\nwith its arguments.\n\n\n> > +print_comp ()\n> > +{\n> > +\tlocal IFS=$'\\n'\n> > +\techo \"${COMPREPLY[*]}\" > out\n> > +}\n> > +\n> > +run_completion ()\n> > +{\n> > +\tlocal -a COMPREPLY _words\n> > +\tlocal _cword\n> > +\t_words=( $1 )\n> > +\t(( _cword = ${#_words[@]} - 1 ))\n> > +\t_git && print_comp\n> > +}\n"},{"id":"189180","messageId":"CAMP44s0_WQNpkVi0yMfaDgzBaUWOhRiS-2qxLtCHFzx71yKrSw@mail.gmail.com","threadId":"30219","inReplyTo":"20120413091236.GC2164@goldbirke","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-13T10:34:46Z","receivedAt":"2012-04-13T10:34:46Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/13 SZEDER Gábor <szeder@ira.uka.de>:\n\n>> +test_expect_success 'basic' '\n>> +     run_completion \"git \\\"\\\"\" &&\n>> +     # built-in\n>> +     grep -q \"^add \\$\" out &&\n>> +     # script\n>> +     grep -q \"^filter-branch \\$\" out &&\n>> +     # plumbing\n>> +     ! grep -q \"^ls-files \\$\" out\n>\n> The && is missing here at the end of the line.\n\nRight.\n\n>> +     run_completion \"git f\" &&\n>> +     ! grep -q -v \"^f\" out\n>\n> grep is not a git command, so I'm not sure, but shouldn't these use\n> 'test_must_fail grep' instead of '! grep'?\n\nI'm not sure. Junio has already queued this, maybe you should send a\npatch on top of that.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189181","messageId":"CAMP44s3g8acV4fjaSvnUo_jnhj40-TWR0az6zOwRNfv9_Qa23g@mail.gmail.com","threadId":"30219","inReplyTo":"20120413094500.GD2164@goldbirke","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-13T10:48:51Z","receivedAt":"2012-04-13T10:48:51Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/13 SZEDER Gábor <szeder@ira.uka.de>:\n> On Fri, Apr 13, 2012 at 11:12:36AM +0200, SZEDER Gábor wrote:\n>> On Thu, Apr 12, 2012 at 12:57:03AM +0300, Felipe Contreras wrote:\n>> > +. \"$GIT_BUILD_DIR/contrib/completion/git-completion.bash\"\n>> > +\n>> > +_get_comp_words_by_ref ()\n>> > +{\n>> > +   while [ $# -gt 0 ]; do\n>> > +           case \"$1\" in\n>> > +           cur)\n>> > +                   cur=${_words[_cword]}\n>> > +                   ;;\n>> > +           prev)\n>> > +                   prev=${_words[_cword-1]}\n>> > +                   ;;\n>> > +           words)\n>> > +                   words=(\"${_words[@]}\")\n>> > +                   ;;\n>> > +           cword)\n>> > +                   cword=$_cword\n>> > +                   ;;\n>> > +           esac\n>> > +           shift\n>> > +   done\n>> > +}\n>>\n>> Git's completion script already implements this function.  Why\n>> override it here?\n>\n> Ah, ok, I think I got it.\n>\n> Of course, the words on the command line must be specified somehow to\n> test completion functions.  But the two implementations of\n> _get_comp_words_by_ref() for bash and zsh in the completion script\n> take the words on the command line from different variables, so we\n> need a common implementation to test completion functions both on bash\n> and zsh.  Hence the _get_comp_words_by_ref() above, which takes the\n> words on the command line and their count from $_words and $_cword,\n> respectively, and run_completion() below, which fills those variables\n> with its arguments.\n\nWell, yeah, that's one reason, but also I don't see the point in\ntrying to fill the internal bash completion variables, maybe there\nwould be some conflicts? Plus, the bash version of\n_get_comp_words_by_ref is rather complicated, so I decided to start\nwith something simple that I could understand and see exactly what's\ngoing on. And for zsh I would definitely prefer to override\n_get_comp_words_by_ref than to mess with the internal variables,\nalthough I haven't found a way to test completion for zsh.\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189182","messageId":"20120413105238.GE2164@goldbirke","threadId":"30219","inReplyTo":"CAMP44s0_WQNpkVi0yMfaDgzBaUWOhRiS-2qxLtCHFzx71yKrSw@mail.gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-13T10:52:38Z","receivedAt":"2012-04-13T10:52:38Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Apr 13, 2012 at 01:34:46PM +0300, Felipe Contreras wrote:\n> >> +     run_completion \"git f\" &&\n> >> +     ! grep -q -v \"^f\" out\n> >\n> > grep is not a git command, so I'm not sure, but shouldn't these use\n> > 'test_must_fail grep' instead of '! grep'?\n> \n> I'm not sure. Junio has already queued this, maybe you should send a\n> patch on top of that.\n\nIt seems that both are used in the test suite, but '! grep' is more\ncommon, so perhaps it's good as it is.\n\n$ git grep '! grep' -- t |wc -l\n136\n$ git grep 'test_must_fail grep' -- t |wc -l\n17\n"},{"id":"189193","messageId":"20120413111437.GF2164@goldbirke","threadId":"30219","inReplyTo":"CAMP44s3g8acV4fjaSvnUo_jnhj40-TWR0az6zOwRNfv9_Qa23g@mail.gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-13T11:14:37Z","receivedAt":"2012-04-13T11:14:37Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Apr 13, 2012 at 01:48:51PM +0300, Felipe Contreras wrote:\n> 2012/4/13 SZEDER Gábor <szeder@ira.uka.de>:\n> > On Fri, Apr 13, 2012 at 11:12:36AM +0200, SZEDER Gábor wrote:\n> >> On Thu, Apr 12, 2012 at 12:57:03AM +0300, Felipe Contreras wrote:\n> >> > +. \"$GIT_BUILD_DIR/contrib/completion/git-completion.bash\"\n> >> > +\n> >> > +_get_comp_words_by_ref ()\n> >> > +{\n> >> > +   while [ $# -gt 0 ]; do\n> >> > +           case \"$1\" in\n> >> > +           cur)\n> >> > +                   cur=${_words[_cword]}\n> >> > +                   ;;\n> >> > +           prev)\n> >> > +                   prev=${_words[_cword-1]}\n> >> > +                   ;;\n> >> > +           words)\n> >> > +                   words=(\"${_words[@]}\")\n> >> > +                   ;;\n> >> > +           cword)\n> >> > +                   cword=$_cword\n> >> > +                   ;;\n> >> > +           esac\n> >> > +           shift\n> >> > +   done\n> >> > +}\n> >>\n> >> Git's completion script already implements this function.  Why\n> >> override it here?\n> >\n> > Ah, ok, I think I got it.\n> >\n> > Of course, the words on the command line must be specified somehow to\n> > test completion functions.  But the two implementations of\n> > _get_comp_words_by_ref() for bash and zsh in the completion script\n> > take the words on the command line from different variables, so we\n> > need a common implementation to test completion functions both on bash\n> > and zsh.  Hence the _get_comp_words_by_ref() above, which takes the\n> > words on the command line and their count from $_words and $_cword,\n> > respectively, and run_completion() below, which fills those variables\n> > with its arguments.\n> \n> Well, yeah, that's one reason, but also I don't see the point in\n> trying to fill the internal bash completion variables, maybe there\n> would be some conflicts? Plus, the bash version of\n> _get_comp_words_by_ref is rather complicated, so I decided to start\n> with something simple that I could understand and see exactly what's\n> going on. And for zsh I would definitely prefer to override\n> _get_comp_words_by_ref than to mess with the internal variables,\n> although I haven't found a way to test completion for zsh.\n\nThe tests are run in a non-interactive shell, which by default doesn't\nload bash completion with its complicated _get_comp_words_by_ref().\nSo these tests use _get_comp_words_by_ref() from git's completion\nscript.\n\n\nAnyway, out of curiosity I quickly tried this on top of b8574ba7 (i.e.\nyour patch from today's pu):\n\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex 3bbec79b..6c1ea956 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -27,27 +27,6 @@ complete ()\n \n . \"$GIT_BUILD_DIR/contrib/completion/git-completion.bash\"\n \n-_get_comp_words_by_ref ()\n-{\n-\twhile [ $# -gt 0 ]; do\n-\t\tcase \"$1\" in\n-\t\tcur)\n-\t\t\tcur=${_words[_cword]}\n-\t\t\t;;\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\t;;\n-\t\tcword)\n-\t\t\tcword=$_cword\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-}\n-\n print_comp ()\n {\n \tlocal IFS=$'\\n'\n@@ -56,10 +35,10 @@ print_comp ()\n \n run_completion ()\n {\n-\tlocal -a COMPREPLY _words\n-\tlocal _cword\n-\t_words=( $1 )\n-\t(( _cword = ${#_words[@]} - 1 ))\n+\tlocal -a COMPREPLY COMP_WORDS\n+\tlocal COMP_CWORD\n+\tCOMP_WORDS=( $1 )\n+\t(( COMP_CWORD = ${#COMP_WORDS[@]} - 1 ))\n \t_git && print_comp\n }\n\ni.e. to set COMP_WORDS and COMP_CWORD in run_completion() and it\nworked.  However, I agree that it feels iffy to mess with a\nshell-specific variable, and I'm afraid that this just happened to\nwork on my system, but it might be broken in previous or future bash\nversions.\n\n\nBest,\nGábor\n"},{"id":"189194","messageId":"871unrzx19.fsf@thomas.inf.ethz.ch","threadId":"30219","inReplyTo":"20120413105238.GE2164@goldbirke","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2012-04-13T11:33:22Z","receivedAt":"2012-04-13T11:33:22Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"SZEDER Gábor <szeder@ira.uka.de> writes:\n\n> On Fri, Apr 13, 2012 at 01:34:46PM +0300, Felipe Contreras wrote:\n>> >> +     run_completion \"git f\" &&\n>> >> +     ! grep -q -v \"^f\" out\n>> >\n>> > grep is not a git command, so I'm not sure, but shouldn't these use\n>> > 'test_must_fail grep' instead of '! grep'?\n>> \n>> I'm not sure. Junio has already queued this, maybe you should send a\n>> patch on top of that.\n>\n> It seems that both are used in the test suite, but '! grep' is more\n> common, so perhaps it's good as it is.\n>\n> $ git grep '! grep' -- t |wc -l\n> 136\n> $ git grep 'test_must_fail grep' -- t |wc -l\n> 17\n\ntest_must_fail catches a segfault or other signal exit as \"bad\", unlike\n! which would accept this.\n\nSince we trust the platform tools to work (on the grounds that you have\nbigger problems if they don't), ! grep is fine.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"189195","messageId":"CAMP44s0C=MV_gxsH9Mk9V6Q27E2E=o1nr3HShBFSTyTYC0Tg4w@mail.gmail.com","threadId":"30219","inReplyTo":"20120413111437.GF2164@goldbirke","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-13T11:56:08Z","receivedAt":"2012-04-13T11:56:08Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/13 SZEDER Gábor <szeder@ira.uka.de>:\n\n> i.e. to set COMP_WORDS and COMP_CWORD in run_completion() and it\n> worked.  However, I agree that it feels iffy to mess with a\n> shell-specific variable, and I'm afraid that this just happened to\n> work on my system, but it might be broken in previous or future bash\n> versions.\n\nYeah, we could explore that possibility later, as\n_get_comp_words_by_ref is part of the completion, and should be tested\nas well, otherwise we might be missing some bugs.\n\nHowever, I wonder if _get_comp_words_by_ref is needed at all. From\nwhat I can see it has to do with '--foo=bar' and 'foo:bar'\ncompletions, which in fact don't work correctly in zsh (I have patches\nfor zsh to fix this though), but by modifying the code that checks for\n'--*=*' stuff we might be able to get rid of it, or at least the call\nto __git_reassemble_comp_words_by_ref. Right?\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"189211","messageId":"7vaa2f2z62.fsf@alter.siamese.dyndns.org","threadId":"30219","inReplyTo":"7vzkag3528.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-13T19:45:57Z","receivedAt":"2012-04-13T19:45:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Felipe Contreras <felipe.contreras@gmail.com> writes:\n>\n>> Do I need to resend the patch?\n>\n> Not necessarily.  If you can eyeball what is queued on 'pu' and gave me an\n> Ack (or send a replacement with \"You stupid, you amended it wrong!\") that\n> should be sufficient.\n\nActually, can we have a follow-up patch to add in-code comment before the\n_get_comp_words_by_ref shell function in t9902 to explain why the test\noverrides this implementation detail?  The script being tested will need\nto maintain _some_ invariants that is expected by this hack in order to\nkeep the test working (or this hack needs to be updated when the updates\nto the completion script need to break the invariants), but without any\nexplanation on what the invariants are, it is making it hard to others to\nupdate the completion script.\n\nThanks.\n"},{"id":"189212","messageId":"7v62d32z1a.fsf@alter.siamese.dyndns.org","threadId":"30219","inReplyTo":"20120413091236.GC2164@goldbirke","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-13T19:48:49Z","receivedAt":"2012-04-13T19:48:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder@ira.uka.de> writes:\n\n>> +_get_comp_words_by_ref ()\n>> +{\n>> +\twhile [ $# -gt 0 ]; do\n>> +\t\tcase \"$1\" in\n>> +\t\tcur)\n>> +\t\t\tcur=${_words[_cword]}\n>> +\t\t\t;;\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\t;;\n>> +\t\tcword)\n>> +\t\t\tcword=$_cword\n>> +\t\t\t;;\n>> +\t\tesac\n>> +\t\tshift\n>> +\tdone\n>> +}\n>\n> Git's completion script already implements this function.  Why\n> override it here?\n\nIt is not \"already implements\" that I am worried about, but it implements\nit differently without explaining why, which is worrying.  I agree it\nneeds to be explained before the function.\n>> +\t# plumbing\n>> +\t! grep -q \"^ls-files \\$\" out\n>\n> The && is missing here at the end of the line.\n\nTrue.\n\n>> +\trun_completion \"git f\" &&\n>> +\t! grep -q -v \"^f\" out\n>\n> grep is not a git command, so I'm not sure, but shouldn't these use\n> 'test_must_fail grep' instead of '! grep'?\n\n\"! grep\" is fine.  We are not trying to catch the case where we break the\nimplementation of \"grep\" to cause it to segfault.\n"},{"id":"189234","messageId":"CAMP44s2zEsvChCVOaCKYoOtU-ny5=zkHwHg8tCjWjL27UX4n8A@mail.gmail.com","threadId":"30219","inReplyTo":"7v62d32z1a.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-14T02:06:17Z","receivedAt":"2012-04-14T02:06:17Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"2012/4/13 Junio C Hamano <gitster@pobox.com>:\n> SZEDER Gábor <szeder@ira.uka.de> writes:\n>\n>>> +_get_comp_words_by_ref ()\n>>> +{\n>>> +    while [ $# -gt 0 ]; do\n>>> +            case \"$1\" in\n>>> +            cur)\n>>> +                    cur=${_words[_cword]}\n>>> +                    ;;\n>>> +            prev)\n>>> +                    prev=${_words[_cword-1]}\n>>> +                    ;;\n>>> +            words)\n>>> +                    words=(\"${_words[@]}\")\n>>> +                    ;;\n>>> +            cword)\n>>> +                    cword=$_cword\n>>> +                    ;;\n>>> +            esac\n>>> +            shift\n>>> +    done\n>>> +}\n>>\n>> Git's completion script already implements this function.  Why\n>> override it here?\n>\n> It is not \"already implements\" that I am worried about, but it implements\n> it differently without explaining why, which is worrying.  I agree it\n> needs to be explained before the function.\n>>> +    # plumbing\n>>> +    ! grep -q \"^ls-files \\$\" out\n>>\n>> The && is missing here at the end of the line.\n>\n> True.\n>\n>>> +    run_completion \"git f\" &&\n>>> +    ! grep -q -v \"^f\" out\n>>\n>> grep is not a git command, so I'm not sure, but shouldn't these use\n>> 'test_must_fail grep' instead of '! grep'?\n>\n> \"! grep\" is fine.  We are not trying to catch the case where we break the\n> implementation of \"grep\" to cause it to segfault.\n\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -27,6 +27,9 @@ complete ()\n\n . \"$GIT_BUILD_DIR/contrib/completion/git-completion.bash\"\n\n+# We don't need this function to actually join words or do anything special.\n+# Also, it's more clean to avoid touching bash's internal completion variables.\n+# So let's override it with a minimal version for testing purposes.\n _get_comp_words_by_ref ()\n {\n        while [ $# -gt 0 ]; do\n@@ -77,7 +80,7 @@ test_expect_success 'basic' '\n        # script\n        grep -q \"^filter-branch \\$\" out &&\n        # plumbing\n-       ! grep -q \"^ls-files \\$\" out\n+       ! grep -q \"^ls-files \\$\" out &&\n\n        run_completion \"git f\" &&\n        ! grep -q -v \"^f\" out\n\n-- \nFelipe Contreras\n"},{"id":"189495","messageId":"20120417003100.GB2299@goldbirke","threadId":"30219","inReplyTo":"1334181423-4391-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"SZEDER Gábor","fromEmail":"szeder@fzi.de","sentAt":"2012-04-17T00:31:00Z","receivedAt":"2012-04-17T00:31:00Z","isPatch":true,"sender":{"key":"szeder@fzi.de","avatar":null},"body":"Hi,\n\n\nI picked up Stephen Boyd's two-patch series[1] to use parse-options to\ngenerate options for git commands, and the following test promply\nfailed (taken from 5c293a6b (tests: add initial bash completion tests,\n2012-04-12)):\n\ntest_expect_success 'double dash \"git checkout\"' '\n        sed -e \"s/Z$//\" >expected <<-\\EOF &&\n        --quiet Z\n        --ours Z\n        --theirs Z\n        --track Z\n        --no-track Z\n        --merge Z\n        --conflict=\n        --orphan Z\n        --patch Z\n        EOF\n        test_completion \"git checkout --\"\n'\n\nNot surprising, the completion script doesn't know about many 'git\ncheckout' long options.  So whenever 'git checkout' learns a new long\noption, this list must be updated.  This won't be more work than the\nupdate of the completion script, so this is probably OK.\n\nBut it got me thinking about what do we actually want to test here?\nWhether the completion script returns the right long options in a\nspecific order upon 'git checkout --<TAB>'?  Or whether _git() works\nproperly and invokes the right command-specific completion function?\nOr whether regular options get a trailing space while options\nexpecting an argument don't?  Or is this sort of an integration test\nand basically all of the above?\n\n\n[1] - http://thread.gmane.org/gmane.comp.version-control.git/195158/focus=195158\n\nBest,\nGábor\n"},{"id":"189500","messageId":"CAMP44s1CTCPThri6mq0NTvD27WTEiwLTfhHCw+nD+8YwApwL=g@mail.gmail.com","threadId":"30219","inReplyTo":"20120417003100.GB2299@goldbirke","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-04-17T06:32:29Z","receivedAt":"2012-04-17T06:32:29Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Tue, Apr 17, 2012 at 3:31 AM, SZEDER Gábor <szeder@fzi.de> wrote:\n> Hi,\n>\n>\n> I picked up Stephen Boyd's two-patch series[1] to use parse-options to\n> generate options for git commands, and the following test promply\n> failed (taken from 5c293a6b (tests: add initial bash completion tests,\n> 2012-04-12)):\n>\n> test_expect_success 'double dash \"git checkout\"' '\n>        sed -e \"s/Z$//\" >expected <<-\\EOF &&\n>        --quiet Z\n>        --ours Z\n>        --theirs Z\n>        --track Z\n>        --no-track Z\n>        --merge Z\n>        --conflict=\n>        --orphan Z\n>        --patch Z\n>        EOF\n>        test_completion \"git checkout --\"\n> '\n>\n> Not surprising, the completion script doesn't know about many 'git\n> checkout' long options.  So whenever 'git checkout' learns a new long\n> option, this list must be updated.  This won't be more work than the\n> update of the completion script, so this is probably OK.\n>\n> But it got me thinking about what do we actually want to test here?\n> Whether the completion script returns the right long options in a\n> specific order upon 'git checkout --<TAB>'?  Or whether _git() works\n> properly and invokes the right command-specific completion function?\n> Or whether regular options get a trailing space while options\n> expecting an argument don't?  Or is this sort of an integration test\n> and basically all of the above?\n\nI don't think the order is relevant, just that all the options are\nthere, and the ones with arguments have a = in there, and the ones\nthat don't, a space.\n\n-- \nFelipe Contreras\n"},{"id":"189513","messageId":"20120417102215.GA22778@goldbirke","threadId":"30219","inReplyTo":"CAMP44s1CTCPThri6mq0NTvD27WTEiwLTfhHCw+nD+8YwApwL=g@mail.gmail.com","subject":"Re: [PATCH v2] tests: add initial bash completion tests","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-17T10:22:15Z","receivedAt":"2012-04-17T10:22:15Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Tue, Apr 17, 2012 at 09:32:29AM +0300, Felipe Contreras wrote:\n> On Tue, Apr 17, 2012 at 3:31 AM, SZEDER Gábor <szeder@fzi.de> wrote:\n> > Hi,\n> >\n> >\n> > I picked up Stephen Boyd's two-patch series[1] to use parse-options to\n> > generate options for git commands, and the following test promply\n> > failed (taken from 5c293a6b (tests: add initial bash completion tests,\n> > 2012-04-12)):\n> >\n> > test_expect_success 'double dash \"git checkout\"' '\n> >        sed -e \"s/Z$//\" >expected <<-\\EOF &&\n> >        --quiet Z\n> >        --ours Z\n> >        --theirs Z\n> >        --track Z\n> >        --no-track Z\n> >        --merge Z\n> >        --conflict=\n> >        --orphan Z\n> >        --patch Z\n> >        EOF\n> >        test_completion \"git checkout --\"\n> > '\n> >\n> > Not surprising, the completion script doesn't know about many 'git\n> > checkout' long options.  So whenever 'git checkout' learns a new long\n> > option, this list must be updated.  This won't be more work than the\n> > update of the completion script, so this is probably OK.\n> >\n> > But it got me thinking about what do we actually want to test here?\n> > Whether the completion script returns the right long options in a\n> > specific order upon 'git checkout --<TAB>'?  Or whether _git() works\n> > properly and invokes the right command-specific completion function?\n> > Or whether regular options get a trailing space while options\n> > expecting an argument don't?  Or is this sort of an integration test\n> > and basically all of the above?\n> \n> I don't think the order is relevant, just that all the options are\n> there, \n\nThe order of options is not relevant in the completion script, because\nBash will sort them alphabetically anyway.  But it is relevant in the\ntest: it fails if the order is changed either in the completion script\nor in the test.\n\n> and the ones with arguments have a = in there, and the ones\n> that don't, a space.\n\nCouldn't we check that better with a test or two for __gitcomp()?\n\nIf a test for __gitcomp() fails, we would immediately have a fairly\ngood idea where to look for the cause of the breakage.  However, if\nthis 'double dash \"git checkout\"' test fails, there are a bunch of\nother things that can possibly cause the failure.\n\nPatch comes in a minute.\n\nBest,\nGábor\n"},{"id":"189514","messageId":"1334658435-30769-1-git-send-email-szeder@ira.uka.de","threadId":"30219","inReplyTo":"20120417102215.GA22778@goldbirke","subject":"[PATCH] tests: add tests for the __gitcomp() completion helper function","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2012-04-17T10:27:15Z","receivedAt":"2012-04-17T10:27:15Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"These tests check that trailing space, prefix, and suffix are added\ncorrectly.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n t/t9902-completion.sh |   85 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 85 insertions(+)\n\ndiff --git a/t/t9902-completion.sh b/t/t9902-completion.sh\nindex cc127320..5bda6b6e 100755\n--- a/t/t9902-completion.sh\n+++ b/t/t9902-completion.sh\n@@ -73,6 +73,91 @@ test_completion ()\n \ttest_cmp expected out\n }\n \n+newline=$'\\n'\n+\n+test_expect_success '__gitcomp - trailing space - options' '\n+\tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n+\t--reuse-message=Z\n+\t--reedit-message=Z\n+\t--reset-author Z\n+\tEOF\n+\t(\n+\t\tlocal -a COMPREPLY &&\n+\t\tcur=\"--re\" &&\n+\t\t__gitcomp \"--dry-run --reuse-message= --reedit-message=\n+\t\t\t\t--reset-author\" &&\n+\t\tIFS=\"$newline\" &&\n+\t\techo \"${COMPREPLY[*]}\" > out\n+\t) &&\n+\ttest_cmp expected out\n+'\n+\n+test_expect_success '__gitcomp - trailing space - config keys' '\n+\tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n+\tbranch.Z\n+\tbranch.autosetupmerge Z\n+\tbranch.autosetuprebase Z\n+\tbrowser.Z\n+\tEOF\n+\t(\n+\t\tlocal -a COMPREPLY &&\n+\t\tcur=\"br\" &&\n+\t\t__gitcomp \"branch. branch.autosetupmerge\n+\t\t\t\tbranch.autosetuprebase browser.\" &&\n+\t\tIFS=\"$newline\" &&\n+\t\techo \"${COMPREPLY[*]}\" > out\n+\t) &&\n+\ttest_cmp expected out\n+'\n+\n+test_expect_success '__gitcomp - option parameter' '\n+\tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n+\trecursive Z\n+\tresolve Z\n+\tEOF\n+\t(\n+\t\tlocal -a COMPREPLY &&\n+\t\tcur=\"--strategy=re\" &&\n+\t\t__gitcomp \"octopus ours recursive resolve subtree\n+\t\t\t\" \"\" \"re\" &&\n+\t\tIFS=\"$newline\" &&\n+\t\techo \"${COMPREPLY[*]}\" > out\n+\t) &&\n+\ttest_cmp expected out\n+'\n+\n+test_expect_success '__gitcomp - prefix' '\n+\tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n+\tbranch.maint.merge Z\n+\tbranch.maint.mergeoptions Z\n+\tEOF\n+\t(\n+\t\tlocal -a COMPREPLY &&\n+\t\tcur=\"branch.me\" &&\n+\t\t__gitcomp \"remote merge mergeoptions rebase\n+\t\t\t\" \"branch.maint.\" \"me\" &&\n+\t\tIFS=\"$newline\" &&\n+\t\techo \"${COMPREPLY[*]}\" > out\n+\t) &&\n+\ttest_cmp expected out\n+'\n+\n+test_expect_success '__gitcomp - suffix' '\n+\tsed -e \"s/Z$//\" >expected <<-\\EOF &&\n+\tbranch.master.Z\n+\tbranch.maint.Z\n+\tEOF\n+\t(\n+\t\tlocal -a COMPREPLY &&\n+\t\tcur=\"branch.me\" &&\n+\t\t__gitcomp \"master maint next pu\n+\t\t\t\" \"branch.\" \"ma\" \".\" &&\n+\t\tIFS=\"$newline\" &&\n+\t\techo \"${COMPREPLY[*]}\" > out\n+\t) &&\n+\ttest_cmp expected out\n+'\n+\n test_expect_success 'basic' '\n \trun_completion \"git \\\"\\\"\" &&\n \t# built-in\n-- \n1.7.10.216.gb52c0\n"}]}