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

Re: [PATCH v2] git am/mailinfo: Don't look at in-body headers when rebasing

From
Jeff King <peff@peff.net>
Date
Nov 19, 2009, 15:36 UTC
Message-ID
<20091119153622.GC6877@coredump.intra.peff.net>
In-Reply-To
<4B050718.8070506@gmail.com>
On Thu, Nov 19, 2009 at 09:51:36AM +0100, Lukas Sandström wrote:
Show 8 quoted lines
> When we are rebasing we know that the header lines in the
> patch are good and that we don't need to pick up any headers
> from the body of the patch.
> 
> This makes it possible to rebase commits whose commit message
> start with "From" or "Date".
> 
> Test vectors by Jeff King.

Thanks, it did end up being a pretty small change. Though I think we may be better off with _both_ patches. Your patch protects the message absolutely during rebasing, and my patch improves the heuristic when applying non-rebase patches.

Show 9 quoted lines
> @@ -771,6 +772,8 @@ static int handle_commit_msg(struct strbuf *line)
>  		return 0;
> 
>  	if (still_looking) {
> +		if (!use_inbody_headers)
> +			still_looking = 0;
>  		strbuf_ltrim(line);
>  		if (!line->len)
>  			return 0;

Hmm. But we still end up in this conditional for the very first line. Which I guess happens to work because the first line we feed is presumably the empty blank line (but I didn't check). Still, wouldn't it be more clear as:

  if (use_inbody_headers && still_looking) {
     ...

in which case still_looking simply becomes irrelevant when the feature is disabled?

Show 9 quoted lines
> +From nobody Mon Sep 17 00:00:00 2001
> +From: A U Thor <a.u.thor@example.com>
> +Subject: check bogus body header (from)
> +Date: Fri, 9 Jun 2006 00:44:16 -0700
> +
> +From: bogosity
> +  - a list
> +  - of stuff
> +---

Since your feature is meant to prevent us looking at inbody headers no matter if they are valid-looking or not, wouldn't a better test be to actually have:

  From: Other Author <other@example.com>

Otherwise, you don't know if it is your feature blocking it, or my patch (if it gets applied on top).

Show 9 quoted lines
> +From nobody Mon Sep 17 00:00:00 2001
> +From: A U Thor <a.u.thor@example.com>
> +Subject: check bogus body header (date)
> +Date: Fri, 9 Jun 2006 00:44:16 -0700
> +
> +Date: bogus
> +
> +and some content
> +
And ditto for the Date here.
-Peff
Previous: Lukas SandströmNext: Lukas Sandström
Message 7 of 13 in “git-mailinfo doesn't stop parsing at the end of the header”
  1. Philip HofstetterNov 18, 2009
  2. Jeff KingNov 18, 2009
  3. Jeff KingNov 18, 2009
  4. git am/mailinfo: Don't look at in-body headers when rebasingLukas Sandström, Nov 18, 2009
  5. Philip HofstetterNov 18, 2009
  6. git am/mailinfo: Don't look at in-body headers when rebasingLukas Sandström, Nov 19, 2009
  7. Jeff KingNov 19, 2009
  8. git am/mailinfo: Don't look at in-body headers when rebasingLukas Sandström, Nov 20, 2009
  9. Philip HofstetterNov 18, 2009
  10. Jeff KingNov 18, 2009
  11. Jakub NarebskiNov 18, 2009
  12. Jeff KingNov 18, 2009
  13. Philip HofstetterNov 18, 2009

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.