{"thread":{"id":"38969","subject":"[bug (maybe)] Applying patch with '---'","startedAt":"2015-04-01T02:37:01Z","lastAt":"2015-04-01T08:06:43Z","messageCount":3,"participants":["Chris Packham","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"258807","messageId":"CAFOYHZC6Qd9wkoWPcTJDxAs9u=FGpHQTkjE-guhwkya0DRVA6g@mail.gmail.com","threadId":"38969","inReplyTo":null,"subject":"[bug (maybe)] Applying patch with '---'","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2015-04-01T02:37:01Z","receivedAt":"2015-04-01T02:37:01Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"Hi List,\n\nSo I was just sent a patch generated with 'git format-patch' that 'git\nam' fails to apply correctly. It applies but part of the commit\nmessage is lost.\n\nThe problem is that the commit message has lines like\n\n--- Foo happened\n    did some things to handle Foo\n--- Bar happened\n    Still processing update from Foo which led to a crash\n\ngit mailinfo seems to discard everything after the first '--- Blah'. I\nknow ^---$ is special but I thought ^---.+$ would be OK. I know git\nmailinfo shouldn't handle garbage input but I guess the problem I have\nis that the patch was generated by git format-patch so surely git\nmailinfo (and therefore git am) _should_ handle something generated by\ngenerated by git format-patch.\n\nDo people agree with my thinking? I'm not sure if it would be\nappropriate for git format-patch to produce a warning or for git\nmailinfo to tighten the matching of '---'.\n\nRegards,\nChris\n"},{"id":"258810","messageId":"xmqqy4mcmkt2.fsf@gitster.dls.corp.google.com","threadId":"38969","inReplyTo":"CAFOYHZC6Qd9wkoWPcTJDxAs9u=FGpHQTkjE-guhwkya0DRVA6g@mail.gmail.com","subject":"Re: [bug (maybe)] Applying patch with '---'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-04-01T06:20:25Z","receivedAt":"2015-04-01T06:20:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Packham <judge.packham@gmail.com> writes:\n\n> So I was just sent a patch generated with 'git format-patch' that 'git\n> am' fails to apply correctly. It applies but part of the commit\n> message is lost.\n>\n> The problem is that the commit message has lines like\n>\n> --- Foo happened\n>     did some things to handle Foo\n> --- Bar happened\n>     Still processing update from Foo which led to a crash\n>\n> git mailinfo seems to discard everything after the first '--- Blah'.\n\nYes, this is well known.  So is a line that begins with \"diff --git\"\nmakes mailinfo to guess that it is the end of the log message.\n\n> ... I know git\n> mailinfo shouldn't handle garbage input but I guess the problem I have\n> is that the patch was generated by git format-patch ...\n\nWhatever message you write format-patch emits without escaping, so\n\"patch was generated by format-patch\" does not guarantee anything,\nunfortunately.  A related similar issue is that a line that begins\nwith \"From \" may be corrupted into a line that begins with \">From \"\nby the time the message hits your mailbox.  These are unfortunately\nsomething you have to know and long-time users learned to avoid\ndoing so unconsciously ;-).\n"},{"id":"258812","messageId":"CAFOYHZDYcF0=kH=L2CZ5=4DBUaGoJihVE9J=s=uuoJQhGGd5yA@mail.gmail.com","threadId":"38969","inReplyTo":"xmqqy4mcmkt2.fsf@gitster.dls.corp.google.com","subject":"Re: [bug (maybe)] Applying patch with '---'","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2015-04-01T08:06:43Z","receivedAt":"2015-04-01T08:06:43Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On Wed, Apr 1, 2015 at 7:20 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Chris Packham <judge.packham@gmail.com> writes:\n>\n>> So I was just sent a patch generated with 'git format-patch' that 'git\n>> am' fails to apply correctly. It applies but part of the commit\n>> message is lost.\n>>\n>> The problem is that the commit message has lines like\n>>\n>> --- Foo happened\n>>     did some things to handle Foo\n>> --- Bar happened\n>>     Still processing update from Foo which led to a crash\n>>\n>> git mailinfo seems to discard everything after the first '--- Blah'.\n>\n> Yes, this is well known.  So is a line that begins with \"diff --git\"\n> makes mailinfo to guess that it is the end of the log message.\n>\n\nSo it looks like code in mailinfo.c to handle\n\n  --- a/file\n  +++ b/file\n\nAlso interprets\n\n  --- Blah\n  more text\n\nas the start of the patch portion. Perhaps mailinfo could search for\nboth the --- and +++ lines before deciding it's the patch portion has\nstarted. Or search for \"diff -\" first and work backwards towards to\ndrop text up to the \"---\".\n\n>> ... I know git\n>> mailinfo shouldn't handle garbage input but I guess the problem I have\n>> is that the patch was generated by git format-patch ...\n>\n> Whatever message you write format-patch emits without escaping, so\n> \"patch was generated by format-patch\" does not guarantee anything,\n> unfortunately.  A related similar issue is that a line that begins\n> with \"From \" may be corrupted into a line that begins with \">From \"\n> by the time the message hits your mailbox.  These are unfortunately\n> something you have to know and long-time users learned to avoid\n> doing so unconsciously ;-).\n\nSo perhaps the newer users need some training wheels built into\nformat-patch :). It'd actually annoy me if it was too intrusive as I\nactually use --- as a light weight alternative to git-notes for\ncommentary I want to include with a patch submission.  But a message\nsaying \"if you send this verbatim commit message text will be lost\"\nwould at least let the user know that something needs attention .\n"}]}