git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug in "git am" when the body starts with spaces

From
Jeff King <peff@peff.net>
Date
Apr 2, 2017, 04:18 UTC
Message-ID
<20170402041838.dzkmibc5lq37sm3h@sigill.intra.peff.net>
In-Reply-To
<CA+55aFwmNuvh_ABtnd_uxXv5HjEjN-+HMZGh_u1OjOCa4dbpmg@mail.gmail.com>
On Sat, Apr 01, 2017 at 12:03:44PM -0700, Linus Torvalds wrote:
Show 12 quoted lines
> On Fri, Mar 31, 2017 at 5:52 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > The continuation logic is oddly complex, and I can't follow the logic.
> > But it is completely broken in how it thinks empty lines are somehow
> > "continuations".
> 
> The attached patch seems to work for me. Comments?
> 
> The logic is fairly simple: if we encounter an empty line, and we have
> pending in-body headers, we flush the pending headers, and mark us as
> no longer in header mode.

Hmm. I think this may work. At first I thought it was too strict in always checking inbody_header_accum.len, because we want this to kick in always, whether there's whitespace continuation or not. But that accumulator has to collect preemptively, before it knows if there's continuation. So it will always be non-empty if we've seen _any_ header, and it will remain non-empty as long as we keep parsing (because any time we flush, we do so in order to handle another line).

IOW, I think this implements the state-machine thing I wrote in my earlier email, because the state "are we inside in-body header parsing" is always reflected by having a non-empty accumulator. It is a bit non-obvious though.

-Peff
Previous: Linus TorvaldsNext: Jonathan Tan
Message 5 of 8 in “Bug in "git am" when the body starts with spaces”
  1. Linus TorvaldsApr 1, 2017
  2. Linus TorvaldsApr 1, 2017
  3. Jeff KingApr 1, 2017
  4. Linus TorvaldsApr 1, 2017
  5. Jeff KingApr 2, 2017
  6. Jonathan TanApr 3, 2017
  7. Jeff KingApr 4, 2017
  8. Junio C HamanoApr 2, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.