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

Re: git-am strips newlines in some commit messages?

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 13, 2008, 09:15 UTC
Message-ID
<m3skzxcj5c.fsf@localhost.localdomain>
In-Reply-To
<20080213083200.GP25954@genesis.frugalware.org>
Miklos Vajna <vmiklos@frugalware.org> writes:
> it seems that in case the second line of a commit message is not empty,
> then git am strips newlines from the commit message. is this expected?
Show 9 quoted lines
> vmiklos@gaia:~/git/t$ cat 0001-foo.patch |git am
> Applying - foo - bar - baz
> vmiklos@gaia:~/git/t$ head -n 6 0001-foo.patch
> From a928423a563201d95cf2e53c5050dbdfb415708e Mon Sep 17 00:00:00 2001
> From: Miklos Vajna <vmiklos@frugalware.org>
> Date: Wed, 13 Feb 2008 09:23:49 +0100
> Subject: [PATCH] - foo
>  - bar
>  - baz

git-am assumes that patch is in email form, and in email there is single empty line separating email headers from email body. What makes git-am mangle your commit message is the fact that email format allows for header to span multiple lines: you have continuation lines to have indented by whitespace. So git-am thinks that " - bar - baz" is continuation of Summary: header.

> of maybe the solution would be that git format-patch inserts two
> newlines after the subject - even if the second line would not empty
> originally.
Decidely. This empty line would always be stripped.
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Miklos Vajna
Message 2 of 2 in “git-am strips newlines in some commit messages?”
  1. Miklos VajnaFeb 13, 2008
  2. Jakub NarebskiFeb 13, 2008

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.