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

Re: serious problem with `git format-patch' & `git am'

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 27, 2009, 02:10 UTC
Message-ID
<7viqmwpr2x.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<m3ljrsvg0e.fsf@localhost.localdomain>
Jakub Narebski <jnareb@gmail.com> writes:
> I think you want undocumented but for the git-am usage (e.g. 'git am
> -h') --rebasing option to git-am, which makes git-am preserve Subject:
> line formatting,...

I have to warn that that one requires you to have proper commit object to begin with. IOW, the first line "From [0-9a-f]{40} date" must record an existing object name.

As you said, "am" is for applying e-mailed patches and filter-branch would be the best fit for fixing imported history, but whichever tool is used, I think it is a mistake to try preserving a "one-line-per-paragraph" format the original poster seems to have, i.e.:

   foo foo foo foo
   bar bar bar bar
   baz baz baz baz

Yes, the low-level could create a commit object with a message like that, but all the Porcelains rely on "paragraphs are separated with a blank line" format. So no matter how the conversion is done, I think it would be a good idea to turn the above into:

   foo foo foo foo
   bar bar bar bar
   baz baz baz baz
if the user wants to keep the resulting history any useful.
To do it with "format-patch | am", you would format it like:
	Subject: foo foo foo foo
        From: author name <author.name@domain>
        Date: author date
        bar bar bar bar
        baz baz baz baz
        
Previous: Jakub NarebskiNext: Brandon Casey
Message 5 of 8 in “serious problem with `git format-patch' & `git am'”
  1. Werner LEMBERGFeb 25, 2009
  2. Johannes SchindelinFeb 26, 2009
  3. Brandon CaseyFeb 26, 2009
  4. Jakub NarebskiFeb 27, 2009
  5. Junio C HamanoFeb 27, 2009
  6. Brandon CaseyFeb 27, 2009
  7. Junio C HamanoFeb 27, 2009
  8. Werner LEMBERGFeb 27, 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.