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

git-mailinfo doesn't stop parsing at the end of the header

From
Philip Hofstetter <phofstetter@sensational.ch>
Date
Nov 18, 2009, 14:20 UTC
Message-ID
<aa2993680911180620g151d8a07t11144d150cd6e29e@mail.gmail.com>
Hello,

today, after working on a topic branch and trying to rebase it on top of the updated master, the rebase failed, complaining about an invalid email address.

Some investigating revealed an interesting quirk in git-mailinfo which seems to be a bit too eager to extract author information: Instead of just looking at the From:-Line in a mails header (git-rebase seems to use git-am which in turn uses git-mailinfo), it searches for "from:" *anywhere* in the mail and uses the last found information as the source for the author information.

In this case, git-format-patch has generated a file that looks something like this:

--------------8<---------------
From d28f21ea8ca64681ba7756417799ceea81ad6873 Mon Sep 17 00:00:00 2001
From: Foo Bar <foo@bar.com>
Date: Tue, 17 Nov 2009 15:27:25 +0100
Subject: blah, blah, blah
from:
- this is a
- list for stuff
---
 list/of/changed/files                   |    1 -
 list/of/changed/files2                  |    1 -
 2 files changed, 0 insertions(+), 2 deletions(-)
the actual diff down here
--------------8<---------------
And when you feed this into mailinfo, this is what you get:
pilif@celes ~/git % git mailinfo /dev/null /dev/null < somepatch.patch
Author:
Email:
Subject: blah, blah, blah
Date: Tue, 17 Nov 2009 15:27:25 +0100
pilif@celes ~/git %

and consequently, anything that depends on the correct author being extracted then fails.

While I know it's rude to have a line beginning with "from:" (and it's even ruder to have a line beginning with "from "), IMHO the header ends at the first blank line and I see no reason to extract author information past the header.

And if this is in fact intended behavior, it should probably not be permitted to create a commit that later on can't be rebased or applied using git-am.

I had a look at the source of git-mailinfo to fix it myself, but this thing does too much for my minimal knowledge in C.

Philip
-- 
Sensational AG
Giesshübelstrasse 62c, Postfach 1966, 8021 Zürich
Tel. +41 43 544 09 60, Mobile  +41 79 341 01 99
info@sensational.ch, http://www.sensational.ch
Next: Jeff King
Message 1 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.