git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-am strips newlines in some commit messages?
@ 2008-02-13  8:32 Miklos Vajna
  2008-02-13  9:15 ` Jakub Narebski
  0 siblings, 1 reply; 2+ messages in thread
From: Miklos Vajna @ 2008-02-13  8:32 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1504 bytes --]

hello,

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?

vmiklos@gaia:~/git/t$ git init
Initialized empty Git repository in .git/
vmiklos@gaia:~/git/t$ echo foo > foo.c
vmiklos@gaia:~/git/t$ git add foo.c
vmiklos@gaia:~/git/t$ git commit -m foo
Created initial commit d0d61f2: foo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo.c
vmiklos@gaia:~/git/t$ echo bar >> foo.c
vmiklos@gaia:~/git/t$ git commit -a
< here is insert "-foo\n-bar\n-baz" >
Created commit a928423: - foo
 1 files changed, 1 insertions(+), 0 deletions(-)
vmiklos@gaia:~/git/t$ git format-patch HEAD^
0001-foo.patch
vmiklos@gaia:~/git/t$ git reset --hard HEAD^
HEAD is now at d0d61f2... foo
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
vmiklos@gaia:~/git/t$ git --no-pager log -1
commit 8af2dc6b5df430e004d6887c3e05d5295a16c947
Author: Miklos Vajna <vmiklos@frugalware.org>
Date:   Wed Feb 13 09:23:49 2008 +0100

    - foo - bar - baz

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.

thanks,
- VMiklos

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git-am strips newlines in some commit messages?
  2008-02-13  8:32 git-am strips newlines in some commit messages? Miklos Vajna
@ 2008-02-13  9:15 ` Jakub Narebski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Narebski @ 2008-02-13  9:15 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: git

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?

> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-13  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-13  8:32 git-am strips newlines in some commit messages? Miklos Vajna
2008-02-13  9:15 ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).