{"thread":{"id":"15087","subject":"git am with MIME","startedAt":"2008-08-19T15:50:14Z","lastAt":"2008-08-21T07:31:31Z","messageCount":6,"participants":["Lea Wiemann","Jeff King","Alex Riesen","Eric Raible"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"87711","messageId":"48AAEBB6.9070306@gmail.com","threadId":"15087","inReplyTo":null,"subject":"git am with MIME","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-08-19T15:50:14Z","receivedAt":"2008-08-19T15:50:14Z","isPatch":false,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"There's still a problem with git am on the current next branch (which\nincludes the recent \"mailinfo: re-fix MIME multipart boundary parsing\"\npatch):\n\n$ wcat -q\n'http://article.gmane.org/gmane.comp.version-control.git/91305/raw' | git am\nfatal: `pos + len' is too far after the end of the buffer\n$\n\nIt seems to be because of the (unusual?) way the patch uses MIME.  Just\nwanted to post this so it doesn't get lost.\n\n-- Lea\n"},{"id":"87715","messageId":"20080819170731.GA2424@coredump.intra.peff.net","threadId":"15087","inReplyTo":"48AAEBB6.9070306@gmail.com","subject":"Re: git am with MIME","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-08-19T17:07:31Z","receivedAt":"2008-08-19T17:07:31Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 19, 2008 at 05:50:14PM +0200, Lea Wiemann wrote:\n\n> $ wcat -q\n> 'http://article.gmane.org/gmane.comp.version-control.git/91305/raw' | git am\n> fatal: `pos + len' is too far after the end of the buffer\n> $\n> \n> It seems to be because of the (unusual?) way the patch uses MIME.  Just\n> wanted to post this so it doesn't get lost.\n\nIt's the From header actually. The patch below should fix it (though it\nsure makes that line of code ugly -- improvements are welcome).\n\n-- >8 --\nmailinfo: avoid violating strbuf assertion\n\nIn handle_from, we calculate the end boundary of a section\nto remove from a strbuf using strcspn like this:\n\n  el = strcspn(buf, set_of_end_boundaries);\n  strbuf_remove(&sb, start, el + 1);\n\nThis works fine if \"el\" is the offset of the boundary\ncharacter, meaning we remove that character. But if the end\nboundary didn't match (that is, we hit the end of the string\nas the boundary instead) then we want just \"el\".\n\nThis manifested itself when we got a 'From' header that had\njust an email address with nothing else in it (the end of\nthe string was the end of the address, rather than, e.g., a\ntrailing '>' character).\n---\n builtin-mailinfo.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-mailinfo.c b/builtin-mailinfo.c\nindex 26d3e5d..e890f7a 100644\n--- a/builtin-mailinfo.c\n+++ b/builtin-mailinfo.c\n@@ -107,7 +107,7 @@ static void handle_from(const struct strbuf *from)\n \tel = strcspn(at, \" \\n\\t\\r\\v\\f>\");\n \tstrbuf_reset(&email);\n \tstrbuf_add(&email, at, el);\n-\tstrbuf_remove(&f, at - f.buf, el + 1);\n+\tstrbuf_remove(&f, at - f.buf, el + (at[el] ? 1 : 0));\n \n \t/* The remainder is name.  It could be \"John Doe <john.doe@xz>\"\n \t * or \"john.doe@xz (John Doe)\", but we have removed the\n-- \n1.6.0.96.g2fad1.dirty\n"},{"id":"87856","messageId":"20080820195734.GE16626@blimp.local","threadId":"15087","inReplyTo":"20080819170731.GA2424@coredump.intra.peff.net","subject":"Re: git am with MIME","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-08-20T19:57:34Z","receivedAt":"2008-08-20T19:57:34Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Jeff King, Tue, Aug 19, 2008 19:07:31 +0200:\n> On Tue, Aug 19, 2008 at 05:50:14PM +0200, Lea Wiemann wrote:\n> @@ -107,7 +107,7 @@ static void handle_from(const struct strbuf *from)\n>  \tel = strcspn(at, \" \\n\\t\\r\\v\\f>\");\n>  \tstrbuf_reset(&email);\n>  \tstrbuf_add(&email, at, el);\n> -\tstrbuf_remove(&f, at - f.buf, el + 1);\n> +\tstrbuf_remove(&f, at - f.buf, el + (at[el] ? 1 : 0));\n>  \n\n +\tstrbuf_remove(&f, at - f.buf, el + !!at[el]);\n\n(Some people'll kill me for that :)\n"},{"id":"87892","messageId":"20080820215833.GA8137@coredump.intra.peff.net","threadId":"15087","inReplyTo":"20080820195734.GE16626@blimp.local","subject":"Re: git am with MIME","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-08-20T21:58:33Z","receivedAt":"2008-08-20T21:58:33Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 20, 2008 at 09:57:34PM +0200, Alex Riesen wrote:\n\n> > -\tstrbuf_remove(&f, at - f.buf, el + 1);\n> > +\tstrbuf_remove(&f, at - f.buf, el + (at[el] ? 1 : 0));\n>  +\tstrbuf_remove(&f, at - f.buf, el + !!at[el]);\n> \n> (Some people'll kill me for that :)\n\nEwwww. ;)\n\n-Peff\n"},{"id":"87939","messageId":"loom.20080821T033231-805@post.gmane.org","threadId":"15087","inReplyTo":"20080820195734.GE16626@blimp.local","subject":"Re: git am with MIME","fromName":"Eric Raible","fromEmail":"raible@gmail.com","sentAt":"2008-08-21T03:34:03Z","receivedAt":"2008-08-21T03:34:03Z","isPatch":false,"sender":{"key":"raible@gmail.com","avatar":null},"body":"Alex Riesen <raa.lkml <at> gmail.com> writes:\n\n> \n> Jeff King, Tue, Aug 19, 2008 19:07:31 +0200:\n> > On Tue, Aug 19, 2008 at 05:50:14PM +0200, Lea Wiemann wrote:\n> > @@ -107,7 +107,7 @@ static void handle_from(const struct strbuf *from)\n> >  \tel = strcspn(at, \" \\n\\t\\r\\v\\f>\");\n> >  \tstrbuf_reset(&email);\n> >  \tstrbuf_add(&email, at, el);\n> > -\tstrbuf_remove(&f, at - f.buf, el + 1);\n> > +\tstrbuf_remove(&f, at - f.buf, el + (at[el] ? 1 : 0));\n> >  \n> \n>  +\tstrbuf_remove(&f, at - f.buf, el + !!at[el]);\n> \n> (Some people'll kill me for that :)\n\nAnd why shouldn't they when:\n\n\tstrbuf_remove(&f, at - f.buf, el + (at[el] != 0));\n\nis infinitely better in every possible way? ;)\n"},{"id":"87948","messageId":"81b0412b0808210031l1caec384x8e085acafd413784@mail.gmail.com","threadId":"15087","inReplyTo":"loom.20080821T033231-805@post.gmane.org","subject":"Re: git am with MIME","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-08-21T07:31:31Z","receivedAt":"2008-08-21T07:31:31Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"2008/8/21 Eric Raible <raible@gmail.com>:\n> Alex Riesen <raa.lkml <at> gmail.com> writes:\n>> (Some people'll kill me for that :)\n>\n> And why shouldn't they when:\n>\n>        strbuf_remove(&f, at - f.buf, el + (at[el] != 0));\n>\n> is infinitely better in every possible way? ;)\n\nBecause that's just as ugly as \"?:\", brackets and all\n"}]}