{"thread":{"id":"46708","subject":"BUG: attempt to trim too many characters","startedAt":"2017-09-05T21:39:14Z","lastAt":"2017-09-13T11:06:37Z","messageCount":9,"participants":["Linus Torvalds","Jeff King","Michael Haggerty"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"327609","messageId":"CA+55aFxW3qcETiMrNk5SqZU+_jtM2Rxeb3mhF=J=c0ChdGm1tg@mail.gmail.com","threadId":"46708","inReplyTo":null,"subject":"BUG: attempt to trim too many characters","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2017-09-05T21:39:05Z","receivedAt":"2017-09-05T21:39:14Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"I just got this with\n\n   gitk --bisect\n\nwhile doing some bisection on my current kernel.\n\nIt happens with \"git rev-parse --bisect\" too, but interestingly, \"git\nlog --bisect\" works fine.\n\nI have not tried to figure out anything further, except that it was\nintroduced by commit b9c8e7f2f (\"prefix_ref_iterator: don't trim too\nmuch\") and it happens with\n\n   iter->iter0->refname = \"refs/bisect/bad\"\n   iter->trim = 15\n\n(where 15 is also the same as the length of that refname).\n\nNot having time to chase this down any more, since I'm busy with the\nmerge window (and that annoying bisect)\n\n              Linus\n"},{"id":"327610","messageId":"20170905215056.4wihyd6hrtvk52yd@sigill.intra.peff.net","threadId":"46708","inReplyTo":"CA+55aFxW3qcETiMrNk5SqZU+_jtM2Rxeb3mhF=J=c0ChdGm1tg@mail.gmail.com","subject":"Re: BUG: attempt to trim too many characters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-09-05T21:50:56Z","receivedAt":"2017-09-05T21:51:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 05, 2017 at 02:39:05PM -0700, Linus Torvalds wrote:\n\n> I just got this with\n> \n>    gitk --bisect\n> \n> while doing some bisection on my current kernel.\n> \n> It happens with \"git rev-parse --bisect\" too, but interestingly, \"git\n> log --bisect\" works fine.\n> \n> I have not tried to figure out anything further, except that it was\n> introduced by commit b9c8e7f2f (\"prefix_ref_iterator: don't trim too\n> much\") and it happens with\n> \n>    iter->iter0->refname = \"refs/bisect/bad\"\n>    iter->trim = 15\n> \n> (where 15 is also the same as the length of that refname).\n> \n> Not having time to chase this down any more, since I'm busy with the\n> merge window (and that annoying bisect)\n\nWhat version of git are you running? This should be fixed by 03df567fbf\n(for_each_bisect_ref(): don't trim refnames, 2017-06-18) which is in\nv2.14.\n\nMore discussion at\n\n  https://public-inbox.org/git/cover.1497792827.git.mhagger@alum.mit.edu/\n\n-Peff\n"},{"id":"327611","messageId":"CA+55aFywhyELmbhAorgTjJZeuNxE-+j2qSP=3d3vqQXNM6p54A@mail.gmail.com","threadId":"46708","inReplyTo":"20170905215056.4wihyd6hrtvk52yd@sigill.intra.peff.net","subject":"Re: BUG: attempt to trim too many characters","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2017-09-05T21:55:08Z","receivedAt":"2017-09-05T21:55:17Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"On Tue, Sep 5, 2017 at 2:50 PM, Jeff King <peff@peff.net> wrote:\n>\n> What version of git are you running? This should be fixed by 03df567fbf\n> (for_each_bisect_ref(): don't trim refnames, 2017-06-18) which is in\n> v2.14.\n\nI'm way more recent than 2.14.\n\nI'm at commit 238e487ea (\"The fifth batch post 2.14\")\n\n              Linus\n"},{"id":"327613","messageId":"20170905220300.isxbt5y5fd2scd6b@sigill.intra.peff.net","threadId":"46708","inReplyTo":"CA+55aFywhyELmbhAorgTjJZeuNxE-+j2qSP=3d3vqQXNM6p54A@mail.gmail.com","subject":"Re: BUG: attempt to trim too many characters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-09-05T22:03:01Z","receivedAt":"2017-09-05T22:03:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 05, 2017 at 02:55:08PM -0700, Linus Torvalds wrote:\n\n> On Tue, Sep 5, 2017 at 2:50 PM, Jeff King <peff@peff.net> wrote:\n> >\n> > What version of git are you running? This should be fixed by 03df567fbf\n> > (for_each_bisect_ref(): don't trim refnames, 2017-06-18) which is in\n> > v2.14.\n> \n> I'm way more recent than 2.14.\n> \n> I'm at commit 238e487ea (\"The fifth batch post 2.14\")\n\nUgh. Bitten again by the fact that rev-parse and revision.c implement\nthe same things in subtly different ways.\n\nThis probably fixes it:\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 2bd28d3c08..9f24004c0a 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -757,8 +757,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--bisect\")) {\n-\t\t\t\tfor_each_ref_in(\"refs/bisect/bad\", show_reference, NULL);\n-\t\t\t\tfor_each_ref_in(\"refs/bisect/good\", anti_reference, NULL);\n+\t\t\t\tfor_each_fullref_in(\"refs/bisect/bad\", show_reference, NULL, 0);\n+\t\t\t\tfor_each_fullref_in(\"refs/bisect/good\", anti_reference, NULL, 0);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (opt_with_value(arg, \"--branches\", &arg)) {\n"},{"id":"327615","messageId":"CA+55aFw==7bqv0dH=cQruXbGjMw-WNrRMreMsYy_4NcrbiWSEA@mail.gmail.com","threadId":"46708","inReplyTo":"20170905220300.isxbt5y5fd2scd6b@sigill.intra.peff.net","subject":"Re: BUG: attempt to trim too many characters","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2017-09-05T22:13:41Z","receivedAt":"2017-09-05T22:13:51Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"On Tue, Sep 5, 2017 at 3:03 PM, Jeff King <peff@peff.net> wrote:\n>\n> This probably fixes it:\n\nYup. Thanks.\n\n           Linus\n"},{"id":"327643","messageId":"20170906115310.kxgjrnmrehm5m32q@sigill.intra.peff.net","threadId":"46708","inReplyTo":"CA+55aFw==7bqv0dH=cQruXbGjMw-WNrRMreMsYy_4NcrbiWSEA@mail.gmail.com","subject":"[PATCH] rev-parse: don't trim bisect refnames","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-09-06T11:53:10Z","receivedAt":"2017-09-06T11:53:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 05, 2017 at 03:13:41PM -0700, Linus Torvalds wrote:\n\n> On Tue, Sep 5, 2017 at 3:03 PM, Jeff King <peff@peff.net> wrote:\n> >\n> > This probably fixes it:\n> \n> Yup. Thanks.\n\nThanks for confirming. Here it is with a commit message and test.\n\n-- >8 --\nSubject: [PATCH] rev-parse: don't trim bisect refnames\n\nUsing for_each_ref_in() with a full refname has always been\na questionable practice, but it became an error with\nb9c8e7f2fb (prefix_ref_iterator: don't trim too much,\n2017-05-22), making \"git rev-parse --bisect\" pretty reliably\nshow a BUG.\n\nCommit 03df567fbf (for_each_bisect_ref(): don't trim\nrefnames, 2017-06-18) fixed this case for revision.c, but\nrev-parse handles this option on its own. We can use the\nsame solution here (and piggy-back on its test).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/rev-parse.c        |  4 ++--\n t/t6002-rev-list-bisect.sh | 18 ++++++++++++++++--\n 2 files changed, 18 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 2bd28d3c08..9f24004c0a 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -757,8 +757,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--bisect\")) {\n-\t\t\t\tfor_each_ref_in(\"refs/bisect/bad\", show_reference, NULL);\n-\t\t\t\tfor_each_ref_in(\"refs/bisect/good\", anti_reference, NULL);\n+\t\t\t\tfor_each_fullref_in(\"refs/bisect/bad\", show_reference, NULL, 0);\n+\t\t\t\tfor_each_fullref_in(\"refs/bisect/good\", anti_reference, NULL, 0);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (opt_with_value(arg, \"--branches\", &arg)) {\ndiff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh\nindex 534903bbd2..a661408038 100755\n--- a/t/t6002-rev-list-bisect.sh\n+++ b/t/t6002-rev-list-bisect.sh\n@@ -236,17 +236,31 @@ test_sequence \"--bisect\"\n #\n #\n \n-test_expect_success '--bisect can default to good/bad refs' '\n+test_expect_success 'set up fake --bisect refs' '\n \tgit update-ref refs/bisect/bad c3 &&\n \tgood=$(git rev-parse b1) &&\n \tgit update-ref refs/bisect/good-$good $good &&\n \tgood=$(git rev-parse c1) &&\n-\tgit update-ref refs/bisect/good-$good $good &&\n+\tgit update-ref refs/bisect/good-$good $good\n+'\n \n+test_expect_success 'rev-list --bisect can default to good/bad refs' '\n \t# the only thing between c3 and c1 is c2\n \tgit rev-parse c2 >expect &&\n \tgit rev-list --bisect >actual &&\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'rev-parse --bisect can default to good/bad refs' '\n+\tgit rev-parse c3 ^b1 ^c1 >expect &&\n+\tgit rev-parse --bisect >actual &&\n+\n+\t# output order depends on the refnames, which in turn depends on\n+\t# the exact sha1s. We just want to make sure we have the same set\n+\t# of lines in any order.\n+\tsort <expect >expect.sorted &&\n+\tsort <actual >actual.sorted &&\n+\ttest_cmp expect.sorted actual.sorted\n+'\n+\n test_done\n-- \n2.14.1.757.g8fad538cea\n\n"},{"id":"327655","messageId":"CAMy9T_FQHei2XgidRqcBPabKCGq2g282KgYDhe-e9XqSjJE1gw@mail.gmail.com","threadId":"46708","inReplyTo":"20170906115310.kxgjrnmrehm5m32q@sigill.intra.peff.net","subject":"Re: [PATCH] rev-parse: don't trim bisect refnames","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2017-09-06T15:09:16Z","receivedAt":"2017-09-06T15:09:24Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On Wed, Sep 6, 2017 at 1:53 PM, Jeff King <peff@peff.net> wrote:\n> [...]\n> Subject: [PATCH] rev-parse: don't trim bisect refnames\n>\n> Using for_each_ref_in() with a full refname has always been\n> a questionable practice, but it became an error with\n> b9c8e7f2fb (prefix_ref_iterator: don't trim too much,\n> 2017-05-22), making \"git rev-parse --bisect\" pretty reliably\n> show a BUG.\n>\n> Commit 03df567fbf (for_each_bisect_ref(): don't trim\n> refnames, 2017-06-18) fixed this case for revision.c, but\n> rev-parse handles this option on its own. We can use the\n> same solution here (and piggy-back on its test).\n\nIt looks good to me.\n\nMichael\n"},{"id":"327912","messageId":"CA+55aFyyHAjEPx6V3X4i7LV-0VGwu2n288ysnpftP1Bx53EX5g@mail.gmail.com","threadId":"46708","inReplyTo":"20170905220300.isxbt5y5fd2scd6b@sigill.intra.peff.net","subject":"Re: BUG: attempt to trim too many characters","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2017-09-13T04:29:49Z","receivedAt":"2017-09-13T04:29:55Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"Just reminding people that this issue would seem to still exist in\ncurrent master..\n\nIt's trivial to show:\n\n   [torvalds@i7 git]$ git bisect start\n   [torvalds@i7 git]$ git bisect bad master\n   [torvalds@i7 git]$ git bisect good master~5\n   Bisecting: 23 revisions left to test after this (roughly 5 steps)\n   [f35a1d75b5ecefaef7b1a8ec55543c82883df82f] Merge branch\n'rs/t3700-clean-leftover' into maint\n   [torvalds@i7 git]$ git rev-parse --bisect\n   fatal: BUG: attempt to trim too many characters\n\n(Note: I use \"git rev-parse --bisect\" to show it as an error on the\ncommand line, but normal people would obviously do \"gitk --bisect\"\nthat then does that \"git rev-parse\" internally and shows a UI error\nbox instead).\n\n              Linus\n\nOn Tue, Sep 5, 2017 at 3:03 PM, Jeff King <peff@peff.net> wrote:\n> On Tue, Sep 05, 2017 at 02:55:08PM -0700, Linus Torvalds wrote:\n>\n>> On Tue, Sep 5, 2017 at 2:50 PM, Jeff King <peff@peff.net> wrote:\n>> >\n>> > What version of git are you running? This should be fixed by 03df567fbf\n>> > (for_each_bisect_ref(): don't trim refnames, 2017-06-18) which is in\n>> > v2.14.\n>>\n>> I'm way more recent than 2.14.\n>>\n>> I'm at commit 238e487ea (\"The fifth batch post 2.14\")\n>\n> Ugh. Bitten again by the fact that rev-parse and revision.c implement\n> the same things in subtly different ways.\n>\n> This probably fixes it:\n>\n> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\n> index 2bd28d3c08..9f24004c0a 100644\n> --- a/builtin/rev-parse.c\n> +++ b/builtin/rev-parse.c\n> @@ -757,8 +757,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n>                                 continue;\n>                         }\n>                         if (!strcmp(arg, \"--bisect\")) {\n> -                               for_each_ref_in(\"refs/bisect/bad\", show_reference, NULL);\n> -                               for_each_ref_in(\"refs/bisect/good\", anti_reference, NULL);\n> +                               for_each_fullref_in(\"refs/bisect/bad\", show_reference, NULL, 0);\n> +                               for_each_fullref_in(\"refs/bisect/good\", anti_reference, NULL, 0);\n>                                 continue;\n>                         }\n>                         if (opt_with_value(arg, \"--branches\", &arg)) {\n"},{"id":"327920","messageId":"20170913110630.mi75i5eeevn5sqpj@sigill.intra.peff.net","threadId":"46708","inReplyTo":"CA+55aFyyHAjEPx6V3X4i7LV-0VGwu2n288ysnpftP1Bx53EX5g@mail.gmail.com","subject":"Re: BUG: attempt to trim too many characters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-09-13T11:06:30Z","receivedAt":"2017-09-13T11:06:37Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 12, 2017 at 09:29:49PM -0700, Linus Torvalds wrote:\n\n> Just reminding people that this issue would seem to still exist in\n> current master..\n\nYeah, the fix is in 1d0538e4860, but it's still working it's way up\nthrough the integration branches.\n\n-Peff\n"}]}