{"thread":{"id":"40515","subject":"please strip MIME-Version and Content-T{ype,ransfer-Encoding} in git am --scissors","startedAt":"2015-10-08T07:17:28Z","lastAt":"2015-10-09T01:43:25Z","messageCount":6,"participants":["Uwe Kleine-König","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"271295","messageId":"20151008071728.GO3982@pengutronix.de","threadId":"40515","inReplyTo":"20151007102822.GT23801@atomide.com","subject":"please strip MIME-Version and Content-T{ype,ransfer-Encoding} in git am --scissors","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2015-10-08T07:17:28Z","receivedAt":"2015-10-08T07:17:28Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello,\n\nwhen applying the mail below (without the '> ' prefix) using git am\n--scissors the result looks like:\n\n\t$ git show\n\tcommit 26ef0606927cc1979faa4166d7f9f3584b5cdc61\n\tAuthor: Tony Lindgren <tony@atomide.com>\n\tDate:   Tue Oct 6 05:36:17 2015 -0700\n\n\t    memory: omap-gpmc: Fix unselectable debug option for GPMC\n\t    \n\t    MIME-Version: 1.0\n\t    Content-Type: text/plain; charset=UTF-8\n\t    Content-Transfer-Encoding: 8bit\n\t    \n\t    Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n\t    added a debug option for GPMC, but somehow managed to keep it unselectable.\n\t    \n\t[...]\n\n\t$ git version\n\tgit version 2.6.0\n\nThe obvious improvement is to strip all headers like git am does without\n--scissors.\n\nIf someone wants a bounce of the original mail, just ask per PM.\n\nBest regards\nUwe\n\n\nOn Wed, Oct 07, 2015 at 03:41:19AM -0700, Tony Lindgren wrote:\n> * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [151007 00:57]:\n> > On Wed, Oct 07, 2015 at 10:45:50AM +0300, Roger Quadros wrote:\n> > > \n> > > How about this instead?\n> > > \n> > > NOTE: Apart from matching the register setup with the bootloader you also need to\n> > > match the GPMC FCLK frequency used by the bootloader else the GPMC timings\n> > > won't be identical with the bootloader timings.\n> > Yeah, sounds better, thanks.\n> > \n> > > Also you might need to build this patch on top of\n> > > http://article.gmane.org/gmane.linux.kernel/2054796\n> > I talked to Tony about this patch yesterday on irc, but I didn't find it\n> > in the archives yet when I sent my mail.\n> \n> Yes sorry here's a repost with your and Roger's changes folded in and\n> edited a bit. Probably best to keep them together with this patch.\n> \n> Does the following look OK to you guys?\n> \n> Regards,\n> \n> Tony\n> \n> 8< ----------------\n> From: Tony Lindgren <tony@atomide.com>\n> Date: Tue, 6 Oct 2015 05:36:17 -0700\n> Subject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\n> MIME-Version: 1.0\n> Content-Type: text/plain; charset=UTF-8\n> Content-Transfer-Encoding: 8bit\n> \n> Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n> added a debug option for GPMC, but somehow managed to keep it unselectable.\n> \n> This probably happened because I had some uncommitted changes and the\n> GPMC option is selected in the platform specific Kconfig.\n> \n> Let's also update the description a bit, it does not mention that\n> enabling the debug option also disables the reset of GPMC controller\n> during the init as pointed out by Uwe Kleine-König\n> <u.kleine-koenig@pengutronix.de> and Roger Quadros <rogerq@ti.com>.\n> \n> Fixes: 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n> Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>\n> Signed-off-by: Tony Lindgren <tony@atomide.com>\n> \n> --- a/drivers/memory/Kconfig\n> +++ b/drivers/memory/Kconfig\n> @@ -58,12 +58,18 @@ config OMAP_GPMC\n>  \t  memory drives like NOR, NAND, OneNAND, SRAM.\n>  \n>  config OMAP_GPMC_DEBUG\n> -\tbool\n> +\tbool \"Enable GPMC debug output and skip reset of GPMC during init\"\n>  \tdepends on OMAP_GPMC\n>  \thelp\n>  \t  Enables verbose debugging mostly to decode the bootloader provided\n> -\t  timings. Enable this during development to configure devices\n> -\t  connected to the GPMC bus.\n> +\t  timings. To preserve the bootloader provided timings, the reset\n> +\t  of GPMC is skipped during init. Enable this during development to\n> +\t  configure devices connected to the GPMC bus.\n> +\n> +\t  NOTE: In addition to matching the register setup with the bootloader\n> +\t  you also need to match the GPMC FCLK frequency used by the\n> +\t  bootloader or else the GPMC timings won't be identical with the\n> +\t  bootloader timings.\n>  \n>  config MVEBU_DEVBUS\n>  \tbool \"Marvell EBU Device Bus Controller\"\n> \n\n-- \nPengutronix e.K.                           | Uwe Kleine-König            |\nIndustrial Linux Solutions                 | http://www.pengutronix.de/  |\n"},{"id":"271345","messageId":"xmqqvbahqhw1.fsf@gitster.mtv.corp.google.com","threadId":"40515","inReplyTo":"20151008071728.GO3982@pengutronix.de","subject":"Re: please strip MIME-Version and Content-T{ype,ransfer-Encoding} in git am --scissors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-10-08T19:28:46Z","receivedAt":"2015-10-08T19:28:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Kleine-König  <u.kleine-koenig@pengutronix.de> writes:\n\n> Hello,\n>\n> when applying the mail below (without the '> ' prefix) using git am\n> --scissors the result looks like:\n>\n> \t$ git show\n> \tcommit 26ef0606927cc1979faa4166d7f9f3584b5cdc61\n> \tAuthor: Tony Lindgren <tony@atomide.com>\n> \tDate:   Tue Oct 6 05:36:17 2015 -0700\n>\n> \t    memory: omap-gpmc: Fix unselectable debug option for GPMC\n> \t    \n> \t    MIME-Version: 1.0\n> \t    Content-Type: text/plain; charset=UTF-8\n> \t    Content-Transfer-Encoding: 8bit\n> \t    \n> \t    Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n> \t    added a debug option for GPMC, but somehow managed to keep it unselectable.\n> \t    \n> \t[...]\n>\n> \t$ git version\n> \tgit version 2.6.0\n>\n> The obvious improvement is to strip all headers like git am does without\n> --scissors.\n\nDoes this have anything to do with scissors, though?  If you remove\neverything before \"8< ---\" in the body of Tony's message (i.e. keep\nthe in-body headers starting with \"From:\" and ending with CTE) and\ntry again, I would suspect that you will get the same result.\n\nI also think that the \"MIME-Version\" thing is what gives this;\nmailinfo and am do not really use it, and consider that the in-body\nheader ends there.\n\nThe right approach to tweak mailinfo to cope with this better would\nbe to keep a bit more state inside mailinfo.c::handle_commit_msg()\nso that if we are (1) using in-body headers, (2) have already seen\n_some_ valid in-body header like \"Subject:\" and \"From: \", and (3)\nhave not seen a blank line, discard lines that we do not care about\n(e.g. \"MIME-VERSION: 1.0\").\n\n\n> If someone wants a bounce of the original mail, just ask per PM.\n\nI have no idea what you are talking about here...\n\n\n> On Wed, Oct 07, 2015 at 03:41:19AM -0700, Tony Lindgren wrote:\n>> * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [151007 00:57]:\n>> > On Wed, Oct 07, 2015 at 10:45:50AM +0300, Roger Quadros wrote:\n>> > > \n>> > > How about this instead?\n>> > > \n>> > > NOTE: Apart from matching the register setup with the bootloader you also need to\n>> > > match the GPMC FCLK frequency used by the bootloader else the GPMC timings\n>> > > won't be identical with the bootloader timings.\n>> > Yeah, sounds better, thanks.\n>> > \n>> > > Also you might need to build this patch on top of\n>> > > http://article.gmane.org/gmane.linux.kernel/2054796\n>> > I talked to Tony about this patch yesterday on irc, but I didn't find it\n>> > in the archives yet when I sent my mail.\n>> \n>> Yes sorry here's a repost with your and Roger's changes folded in and\n>> edited a bit. Probably best to keep them together with this patch.\n>> \n>> Does the following look OK to you guys?\n>> \n>> Regards,\n>> \n>> Tony\n>> \n>> 8< ----------------\n>> From: Tony Lindgren <tony@atomide.com>\n>> Date: Tue, 6 Oct 2015 05:36:17 -0700\n>> Subject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\n>> MIME-Version: 1.0\n>> Content-Type: text/plain; charset=UTF-8\n>> Content-Transfer-Encoding: 8bit\n>> \n>> Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n>> added a debug option for GPMC, but somehow managed to keep it unselectable.\n>> \n>> This probably happened because I had some uncommitted changes and the\n>> ...\n"},{"id":"271346","messageId":"20151008193707.GT3982@pengutronix.de","threadId":"40515","inReplyTo":"xmqqvbahqhw1.fsf@gitster.mtv.corp.google.com","subject":"Re: please strip MIME-Version and Content-T{ype,ransfer-Encoding} in git am --scissors","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2015-10-08T19:37:07Z","receivedAt":"2015-10-08T19:37:07Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello Junio,\n\nOn Thu, Oct 08, 2015 at 12:28:46PM -0700, Junio C Hamano wrote:\n> Uwe Kleine-König  <u.kleine-koenig@pengutronix.de> writes:\n> \n> > Hello,\n> >\n> > when applying the mail below (without the '> ' prefix) using git am\n> > --scissors the result looks like:\n> >\n> > \t$ git show\n> > \tcommit 26ef0606927cc1979faa4166d7f9f3584b5cdc61\n> > \tAuthor: Tony Lindgren <tony@atomide.com>\n> > \tDate:   Tue Oct 6 05:36:17 2015 -0700\n> >\n> > \t    memory: omap-gpmc: Fix unselectable debug option for GPMC\n> > \t    \n> > \t    MIME-Version: 1.0\n> > \t    Content-Type: text/plain; charset=UTF-8\n> > \t    Content-Transfer-Encoding: 8bit\n> > \t    \n> > \t    Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n> > \t    added a debug option for GPMC, but somehow managed to keep it unselectable.\n> > \t    \n> > \t[...]\n> >\n> > \t$ git version\n> > \tgit version 2.6.0\n> >\n> > The obvious improvement is to strip all headers like git am does without\n> > --scissors.\n> \n> Does this have anything to do with scissors, though?  If you remove\n> everything before \"8< ---\" in the body of Tony's message (i.e. keep\n> the in-body headers starting with \"From:\" and ending with CTE) and\n> try again, I would suspect that you will get the same result.\nNo, you're wrong here:\n\nukl@dude.ptx:~/gsrc/linux$ head ~/tmp/1444332661.3982_89.ptx\\:2\\,RS \nFrom: Tony Lindgren <tony@atomide.com>\nDate: Tue, 6 Oct 2015 05:36:17 -0700\nSubject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nCommit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\nadded a debug option for GPMC, but somehow managed to keep it unselectable.\n\nukl@dude.ptx:~/gsrc/linux$ git am ~/tmp/1444332661.3982_89.ptx\\:2\\,RS\nApplying: memory: omap-gpmc: Fix unselectable debug option for GPMC\nukl@dude.ptx:~/gsrc/linux$ git cat-file commit HEAD\ntree bab01e3e0d0bdd715b86cf7d5c9e8bb9768a30dc\nparent c6fa8e6de3dc420cba092bf155b2ed25bcd537f7\nauthor Tony Lindgren <tony@atomide.com> 1444134977 -0700\ncommitter Uwe Kleine-König <u.kleine-koenig@pengutronix.de> 1444332782 +0200\n\nmemory: omap-gpmc: Fix unselectable debug option for GPMC\n\nCommit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\nadded a debug option for GPMC, but somehow managed to keep it unselectable.\n\nThis probably happened because I had some uncommitted changes and the\nGPMC option is selected in the platform specific Kconfig.\n\nLet's also update the description a bit, it does not mention that\nenabling the debug option also disables the reset of GPMC controller\nduring the init as pointed out by Uwe Kleine-König\n<u.kleine-koenig@pengutronix.de> and Roger Quadros <rogerq@ti.com>.\n\nFixes: 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\nReported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>\nSigned-off-by: Tony Lindgren <tony@atomide.com>\n\n> I also think that the \"MIME-Version\" thing is what gives this;\n> mailinfo and am do not really use it, and consider that the in-body\n> header ends there.\n\nI failed to follow you here.\n\n> The right approach to tweak mailinfo to cope with this better would\n> be to keep a bit more state inside mailinfo.c::handle_commit_msg()\n> so that if we are (1) using in-body headers, (2) have already seen\n> _some_ valid in-body header like \"Subject:\" and \"From: \", and (3)\n> have not seen a blank line, discard lines that we do not care about\n> (e.g. \"MIME-VERSION: 1.0\").\n\nThat sound's right.\n \n> > If someone wants a bounce of the original mail, just ask per PM.\n> \n> I have no idea what you are talking about here...\n\nThe result would be that a copy of the original mail would hit your mailbox if\nyou asked per private mail (PM).\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                           | Uwe Kleine-König            |\nIndustrial Linux Solutions                 | http://www.pengutronix.de/  |\n"},{"id":"271348","messageId":"xmqqio6hqg9a.fsf@gitster.mtv.corp.google.com","threadId":"40515","inReplyTo":"20151008193707.GT3982@pengutronix.de","subject":"Re: please strip MIME-Version and Content-T{ype,ransfer-Encoding} in git am --scissors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-10-08T20:04:01Z","receivedAt":"2015-10-08T20:04:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Kleine-König  <u.kleine-koenig@pengutronix.de> writes:\n\n>> Does this have anything to do with scissors, though?  If you remove\n>> everything before \"8< ---\" in the body of Tony's message (i.e. keep\n>> the in-body headers starting with \"From:\" and ending with CTE) and\n>> try again, I would suspect that you will get the same result.\n> No, you're wrong here:\n>\n> ukl@dude.ptx:~/gsrc/linux$ head ~/tmp/1444332661.3982_89.ptx\\:2\\,RS \n> From: Tony Lindgren <tony@atomide.com>\n> Date: Tue, 6 Oct 2015 05:36:17 -0700\n> Subject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\n> MIME-Version: 1.0\n> Content-Type: text/plain; charset=UTF-8\n> Content-Transfer-Encoding: 8bit\n>\n> Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n> added a debug option for GPMC, but somehow managed to keep it unselectable.\n\nI think you are the one who misread my question.  I said \"keep the\nin-body headers\", didn't I?  If you did the \"head\", then you would\nsee something like this:\n\n\n> ukl@dude.ptx:~/gsrc/linux$ head ~/tmp/1444332661.3982_89.ptx\\:2\\,RS \n> From: Tony Lindgren <tony@atomide.com>\n> Date: Tue, 6 Oct 2015 05:36:17 -0700\n> Subject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\n> ... probably Received: and all other junk from your mailbox ...\n>\n> From: Tony Lindgren <tony@atomide.com>\n> Date: Tue, 6 Oct 2015 05:36:17 -0700\n> Subject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\n> MIME-Version: 1.0\n> Content-Type: text/plain; charset=UTF-8\n> Content-Transfer-Encoding: 8bit\n>\n> Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n> added a debug option for GPMC, but somehow managed to keep it unselectable.\n\n>> I also think that the \"MIME-Version\" thing is what gives this;\n>> mailinfo and am do not really use it, and consider that the in-body\n>> header ends there.\n>\n> I failed to follow you here.\n\nI think if you tried the example with in-body header, you will see\nwhat I meant.\n\n>\n>> The right approach to tweak mailinfo to cope with this better would\n>> be to keep a bit more state inside mailinfo.c::handle_commit_msg()\n>> so that if we are (1) using in-body headers, (2) have already seen\n>> _some_ valid in-body header like \"Subject:\" and \"From: \", and (3)\n>> have not seen a blank line, discard lines that we do not care about\n>> (e.g. \"MIME-VERSION: 1.0\").\n>\n> That sound's right.\n"},{"id":"271351","messageId":"20151008202343.GU3982@pengutronix.de","threadId":"40515","inReplyTo":"xmqqio6hqg9a.fsf@gitster.mtv.corp.google.com","subject":"Re: please strip MIME-Version and Content-T{ype,ransfer-Encoding} in git am --scissors","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2015-10-08T20:23:43Z","receivedAt":"2015-10-08T20:23:43Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello Junio,\n\nOn Thu, Oct 08, 2015 at 01:04:01PM -0700, Junio C Hamano wrote:\n> Uwe Kleine-König  <u.kleine-koenig@pengutronix.de> writes:\n> \n> >> Does this have anything to do with scissors, though?  If you remove\n> >> everything before \"8< ---\" in the body of Tony's message (i.e. keep\n> >> the in-body headers starting with \"From:\" and ending with CTE) and\n> >> try again, I would suspect that you will get the same result.\n> > No, you're wrong here:\n> >\n> > ukl@dude.ptx:~/gsrc/linux$ head ~/tmp/1444332661.3982_89.ptx\\:2\\,RS \n> > From: Tony Lindgren <tony@atomide.com>\n> > Date: Tue, 6 Oct 2015 05:36:17 -0700\n> > Subject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\n> > MIME-Version: 1.0\n> > Content-Type: text/plain; charset=UTF-8\n> > Content-Transfer-Encoding: 8bit\n> >\n> > Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n> > added a debug option for GPMC, but somehow managed to keep it unselectable.\n> \n> I think you are the one who misread my question.  I said \"keep the\n> in-body headers\", didn't I?  If you did the \"head\", then you would\n> see something like this:\n\nAh got it. Yes, you're right. (Subject and Date are actually different\nbetween real and in-body headers, but that's not important. git am picks\nup the in-body headers.)\n \n> > ukl@dude.ptx:~/gsrc/linux$ head ~/tmp/1444332661.3982_89.ptx\\:2\\,RS \n> > From: Tony Lindgren <tony@atomide.com>\n> > Date: Tue, 6 Oct 2015 05:36:17 -0700\n> > Subject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\n> > ... probably Received: and all other junk from your mailbox ...\n> >\n> > From: Tony Lindgren <tony@atomide.com>\n> > Date: Tue, 6 Oct 2015 05:36:17 -0700\n> > Subject: [PATCH] memory: omap-gpmc: Fix unselectable debug option for GPMC\n> > MIME-Version: 1.0\n> > Content-Type: text/plain; charset=UTF-8\n> > Content-Transfer-Encoding: 8bit\n> >\n> > Commit 63aa945b1013 (\"memory: omap-gpmc: Add Kconfig option for debug\")\n> > added a debug option for GPMC, but somehow managed to keep it unselectable.\n> \n> >> I also think that the \"MIME-Version\" thing is what gives this;\n> >> mailinfo and am do not really use it, and consider that the in-body\n> >> header ends there.\n> >\n> > I failed to follow you here.\n> \n> I think if you tried the example with in-body header, you will see\n> what I meant.\n> \n> >\n> >> The right approach to tweak mailinfo to cope with this better would\n> >> be to keep a bit more state inside mailinfo.c::handle_commit_msg()\n> >> so that if we are (1) using in-body headers, (2) have already seen\n> >> _some_ valid in-body header like \"Subject:\" and \"From: \", and (3)\n> >> have not seen a blank line, discard lines that we do not care about\n> >> (e.g. \"MIME-VERSION: 1.0\").\n\nThe right thing should also happen if MIME-Version comes above Subject\nin the body but other than that I'm with you here.\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                           | Uwe Kleine-König            |\nIndustrial Linux Solutions                 | http://www.pengutronix.de/  |\n"},{"id":"271361","messageId":"xmqqtwq0q0jm.fsf@gitster.mtv.corp.google.com","threadId":"40515","inReplyTo":"xmqqio6hqg9a.fsf@gitster.mtv.corp.google.com","subject":"[PATCH] mailinfo: ignore in-body header that we do not care about","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-10-09T01:43:25Z","receivedAt":"2015-10-09T01:43:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git mailinfo\" (hence \"git am\") understands some well-known headers,\nlike \"Subject: \", \"Date: \" and \"From: \", placed at the beginning of\nthe message body (and the \"--scissors\" can discard the part of the\nbody before a scissors-mark).  However, some people throw other\nkinds of header-looking things there, expecting them to be\ndiscarded.\n\nFinding and discarding anything that looks like RFC2822 header is\nnot a right solution.  The body of the message may start with a line\nthat begins with a word followed by a colon that is a legitimate\npart of the message that should not be discarded.\n\nInstead, keep reading non-blank lines once we see an in-body header\nat the beginning and discard them.  Nobody will be insane enough to\nreorder the headers to read like this:\n\n    Garbage-non-in-body-header: here\n    Subject: in-body subject\n\n    Here is the body of the commit log.\n\nbut it is common for lazy or misguided people to leave non-header\nmaterials in-body like this:\n\n    From: Junio C Hamano <gitster@pobox.com>\n    Date: Mon, 28 Sep 2015 19:19:27 -0700\n    Subject: [PATCH] Git 2.6.1\n    MIME-Version: 1.0\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n I think it is wrong for the in-body header codepath to pay\n attention to content-transfer-encodings and stuff, but that is a\n separate issue.\n\n Also if you remove the \"does the line even look like a header?\"\n check, some tests in t5100 starts failing.  E.g.\n\n    From nobody Mon Sep 17 00:00:00 2001\n    From: A U Thor <a.u.thor@example.com>\n    Subject: check bogus body header (from)\n    Date: Fri, 9 Jun 2006 00:44:16 -0700\n\n    From: bogosity\n      - a list\n      - of stuff\n\n wants to make sure the list of two bulletted-items are in the\n commit log, and the in-body From: line gets used.\n\n So I dunno.  I am not entirely convinced that this is a good\n change.\n\n builtin/mailinfo.c  | 34 +++++++++++++++++++++++++++++++---\n t/t5100-mailinfo.sh |  3 ++-\n t/t5100/info0018    |  5 +++++\n t/t5100/msg0018     |  2 ++\n t/t5100/patch0018   |  6 ++++++\n t/t5100/sample.mbox | 18 ++++++++++++++++++\n 6 files changed, 64 insertions(+), 4 deletions(-)\n create mode 100644 t/t5100/info0018\n create mode 100644 t/t5100/msg0018\n create mode 100644 t/t5100/patch0018\n\ndiff --git a/builtin/mailinfo.c b/builtin/mailinfo.c\nindex 999a525..169ee54 100644\n--- a/builtin/mailinfo.c\n+++ b/builtin/mailinfo.c\n@@ -787,18 +787,46 @@ static int is_scissors_line(const struct strbuf *line)\n \n static int handle_commit_msg(struct strbuf *line)\n {\n+\t/*\n+\t * Are we still scanning and discarding in-body headers?\n+\t * It is initially set to 1, set to 2 when we do see a\n+\t * valid in-body header.\n+\t */\n \tstatic int still_looking = 1;\n+\tint is_empty_line;\n \n \tif (!cmitmsg)\n \t\treturn 0;\n \n-\tif (still_looking) {\n-\t\tif (!line->len || (line->len == 1 && line->buf[0] == '\\n'))\n+\tis_empty_line = (!line->len || (line->len == 1 && line->buf[0] == '\\n'));\n+\tif (still_looking == 1) {\n+\t\t/*\n+\t\t * Haven't seen a known in-body header; discard an empty line.\n+\t\t */\n+\t\tif (is_empty_line)\n \t\t\treturn 0;\n \t}\n \n \tif (use_inbody_headers && still_looking) {\n-\t\tstill_looking = check_header(line, s_hdr_data, 0);\n+\t\tint is_known_header = check_header(line, s_hdr_data, 0);\n+\n+\t\tif (still_looking == 2) {\n+\t\t\t/*\n+\t\t\t * an empty line after the in-body header block,\n+\t\t\t * or a line obviously not an attempt to invent\n+\t\t\t * an unsupported in-body header.\n+\t\t\t */\n+\t\t\tif (is_empty_line || !is_rfc2822_header(line))\n+\t\t\t\tstill_looking = 0;\n+\t\t\tif (is_empty_line)\n+\t\t\t\treturn 0;\n+\t\t\t/* otherwise do not discard the line, but keep going */\n+\t\t} else if (is_known_header) {\n+\t\t\tstill_looking = 2;\n+\t\t} else if (still_looking != 2) {\n+\t\t\tstill_looking = 0;\n+\t\t}\n+\n \t\tif (still_looking)\n \t\t\treturn 0;\n \t} else\ndiff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh\nindex e97cfb2..3ce041b 100755\n--- a/t/t5100-mailinfo.sh\n+++ b/t/t5100-mailinfo.sh\n@@ -11,7 +11,8 @@ test_expect_success 'split sample box' \\\n \t'git mailsplit -o. \"$TEST_DIRECTORY\"/t5100/sample.mbox >last &&\n \tlast=`cat last` &&\n \techo total is $last &&\n-\ttest `cat last` = 17'\n+\ttest `cat last` = 18\n+'\n \n check_mailinfo () {\n \tmail=$1 opt=$2\ndiff --git a/t/t5100/info0018 b/t/t5100/info0018\nnew file mode 100644\nindex 0000000..ec671fc\n--- /dev/null\n+++ b/t/t5100/info0018\n@@ -0,0 +1,5 @@\n+Author: A U Thor\n+Email: a.u.thor@example.com\n+Subject: A E I O U\n+Date: Mon, 17 Sep 2012 14:23:49 -0700\n+\ndiff --git a/t/t5100/msg0018 b/t/t5100/msg0018\nnew file mode 100644\nindex 0000000..2ee0900\n--- /dev/null\n+++ b/t/t5100/msg0018\n@@ -0,0 +1,2 @@\n+New content here\n+\ndiff --git a/t/t5100/patch0018 b/t/t5100/patch0018\nnew file mode 100644\nindex 0000000..35cf84c\n--- /dev/null\n+++ b/t/t5100/patch0018\n@@ -0,0 +1,6 @@\n+diff --git a/foo b/foo\n+index e69de29..d95f3ad 100644\n+--- a/foo\n++++ b/foo\n+@@ -0,0 +1 @@\n++New content\ndiff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox\nindex 8b2ae06..d7c5878 100644\n--- a/t/t5100/sample.mbox\n+++ b/t/t5100/sample.mbox\n@@ -406,6 +406,7 @@ Subject: re: [PATCH] another patch\n \n From: A U Thor <a.u.thor@example.com>\n Subject: [PATCH] another patch\n+\n >Here is an empty patch from A U Thor.\n \n Hey you forgot the patch!\n@@ -699,3 +700,20 @@ index e69de29..d95f3ad 100644\n +++ b/foo\n @@ -0,0 +1 @@\n +New content\n+From nobody Mon Sep 17 00:00:00 2001\n+From: A U Thor <a.u.thor@example.com>\n+Subject: Re: some discussion title\n+Date: Mon, 17 Sep 2012 14:23:49 -0700\n+\n+Subject: A E I O U\n+MIME-VERSION: 1.0\n+Garbage: Not a valid in-body header\n+\n+New content here\n+\n+diff --git a/foo b/foo\n+index e69de29..d95f3ad 100644\n+--- a/foo\n++++ b/foo\n+@@ -0,0 +1 @@\n++New content\n-- \n2.6.1-296-ge15092e\n"}]}