Re: [PATCH] sequencer: require trailing NL in footers
- From
Stefan Beller <sbeller@google.com>
- Date
- Apr 25, 2017, 21:04 UTC
- Message-ID
- <CAGZ79kapU5AL_iPJXCavCKAQ0Fw=pqWZS4F6Vri-Q1M1WMVs_w@mail.gmail.com>
- In-Reply-To
- <20170425190651.8910-1-jonathantanmy@google.com>
On Tue, Apr 25, 2017 at 12:06 PM, Jonathan Tan <jonathantanmy@google.com> wrote:
Show 28 quoted lines
> In commit 967dfd4 ("sequencer: use trailer's trailer layout",
> 2016-11-29), sequencer was taught to use the same mechanism as
> interpret-trailers to determine the nature of the trailer of a commit
> message (referred to as the "footer" in sequencer.c). However, the
> requirement that a footer end in a newline character was inadvertently
> removed. Restore that requirement.
>
> While writing this commit, I noticed that if the "ignore_footer"
> parameter in "has_conforming_footer" is greater than the distance
> between the trailer start and sb->len, "has_conforming_footer" will
> return an unexpected result. This does not occur in practice, because
> "ignore_footer" is either zero or the return value of an invocation to
> "ignore_non_trailer", which only skips empty lines and comment lines.
> This commit contains a comment explaining this in the function's
> documentation.
>
> Reported-by: Brian Norris <computersforpeace@gmail.com>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
>
> Thanks for the bug report. Here's a fix - I've verified this with the
> way to reproduce provided in the original e-mail, and it seems to work
> now.
>
> The commit message of the referenced commit
> (7b309aef0463340d3ad5449d1f605d14e10a4225) does not end in a newline,
> which is probably why different behavior was observed with this commit
> (as compared to others).Thanks for the fix. :) Do we want to test for this use case in the future?
Show 11 quoted lines
> @@ -151,6 +151,12 @@ static const char *get_todo_path(const struct replay_opts *opts) > * Returns 1 for conforming footer > * Returns 2 when sob exists within conforming footer > * Returns 3 when sob exists within conforming footer as last entry > + * > + * A footer that does not end in a newline is considered non-conforming. > + * > + * ignore_footer, if not zero, should be the return value of an invocation to > + * ignore_non_trailer. See the documentation of that function for more > + * information. > */
Makes sense. Maybe s/ignore_non_trailer/ignore_non_trailer()/ which makes it easier to recognize it as a function? I'd also drop the last sentence as it is implied in the previous sentence (sort of).
Thanks, Stefan