{"thread":{"id":"12069","subject":"git-am strips newlines in some commit messages?","startedAt":"2008-02-13T08:32:00Z","lastAt":"2008-02-13T09:15:02Z","messageCount":2,"participants":["Miklos Vajna","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"68612","messageId":"20080213083200.GP25954@genesis.frugalware.org","threadId":"12069","inReplyTo":null,"subject":"git-am strips newlines in some commit messages?","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-02-13T08:32:00Z","receivedAt":"2008-02-13T08:32:00Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"hello,\n\nit seems that in case the second line of a commit message is not empty,\nthen git am strips newlines from the commit message. is this expected?\n\nvmiklos@gaia:~/git/t$ git init\nInitialized empty Git repository in .git/\nvmiklos@gaia:~/git/t$ echo foo > foo.c\nvmiklos@gaia:~/git/t$ git add foo.c\nvmiklos@gaia:~/git/t$ git commit -m foo\nCreated initial commit d0d61f2: foo\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 foo.c\nvmiklos@gaia:~/git/t$ echo bar >> foo.c\nvmiklos@gaia:~/git/t$ git commit -a\n< here is insert \"-foo\\n-bar\\n-baz\" >\nCreated commit a928423: - foo\n 1 files changed, 1 insertions(+), 0 deletions(-)\nvmiklos@gaia:~/git/t$ git format-patch HEAD^\n0001-foo.patch\nvmiklos@gaia:~/git/t$ git reset --hard HEAD^\nHEAD is now at d0d61f2... foo\nvmiklos@gaia:~/git/t$ cat 0001-foo.patch |git am\nApplying - foo - bar - baz\nvmiklos@gaia:~/git/t$ head -n 6 0001-foo.patch\nFrom a928423a563201d95cf2e53c5050dbdfb415708e Mon Sep 17 00:00:00 2001\nFrom: Miklos Vajna <vmiklos@frugalware.org>\nDate: Wed, 13 Feb 2008 09:23:49 +0100\nSubject: [PATCH] - foo\n - bar\n - baz\nvmiklos@gaia:~/git/t$ git --no-pager log -1\ncommit 8af2dc6b5df430e004d6887c3e05d5295a16c947\nAuthor: Miklos Vajna <vmiklos@frugalware.org>\nDate:   Wed Feb 13 09:23:49 2008 +0100\n\n    - foo - bar - baz\n\nof maybe the solution would be that git format-patch inserts two\nnewlines after the subject - even if the second line would not empty\noriginally.\n\nthanks,\n- VMiklos\n"},{"id":"68618","messageId":"m3skzxcj5c.fsf@localhost.localdomain","threadId":"12069","inReplyTo":"20080213083200.GP25954@genesis.frugalware.org","subject":"Re: git-am strips newlines in some commit messages?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-13T09:15:02Z","receivedAt":"2008-02-13T09:15:02Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> it seems that in case the second line of a commit message is not empty,\n> then git am strips newlines from the commit message. is this expected?\n\n> vmiklos@gaia:~/git/t$ cat 0001-foo.patch |git am\n> Applying - foo - bar - baz\n> vmiklos@gaia:~/git/t$ head -n 6 0001-foo.patch\n> From a928423a563201d95cf2e53c5050dbdfb415708e Mon Sep 17 00:00:00 2001\n> From: Miklos Vajna <vmiklos@frugalware.org>\n> Date: Wed, 13 Feb 2008 09:23:49 +0100\n> Subject: [PATCH] - foo\n>  - bar\n>  - baz\n\ngit-am assumes that patch is in email form, and in email there is\nsingle empty line separating email headers from email body. What makes\ngit-am mangle your commit message is the fact that email format allows\nfor header to span multiple lines: you have continuation lines to have\nindented by whitespace. So git-am thinks that \" - bar - baz\" is\ncontinuation of Summary: header.\n\n> of maybe the solution would be that git format-patch inserts two\n> newlines after the subject - even if the second line would not empty\n> originally.\n\nDecidely. This empty line would always be stripped.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}