From: Jonathan Tan <jonathantanmy@google.com>
To: Jeff King <peff@peff.net>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: Bug in "git am" when the body starts with spaces
Date: Mon, 3 Apr 2017 10:42:46 -0700 [thread overview]
Message-ID: <f3f2b6f0-c6bb-f50a-5030-61afe941eb23@google.com> (raw)
In-Reply-To: <20170402041838.dzkmibc5lq37sm3h@sigill.intra.peff.net>
Thanks, everyone, for looking into this.
On 04/01/2017 09:18 PM, Jeff King wrote:
> On Sat, Apr 01, 2017 at 12:03:44PM -0700, Linus Torvalds wrote:
>> 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.
About obviousness, I think of a non-empty accumulator merely
representing that the next line could potentially be a continuation
line. And it is coincidence that this implies "are we inside in-body
header parsing"; if not all in-body header lines could be "continued",
there would be no such implication.
mi->inbody_header_accum.len is already used in check_inbody_header to
mean "could the next line potentially be a continuation line" and to
trigger a check for a negative criterion (in this case, a scissors
line). I think it's fine to do the same thing, the negative criterion
here being a blank line.
next prev parent reply other threads:[~2017-04-03 17:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-01 0:24 Bug in "git am" when the body starts with spaces Linus Torvalds
2017-04-01 0:52 ` Linus Torvalds
2017-04-01 5:27 ` Jeff King
2017-04-01 19:03 ` Linus Torvalds
2017-04-02 4:18 ` Jeff King
2017-04-03 17:42 ` Jonathan Tan [this message]
2017-04-04 6:50 ` Jeff King
2017-04-02 17:35 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f3f2b6f0-c6bb-f50a-5030-61afe941eb23@google.com \
--to=jonathantanmy@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).