When using a text file for a commit message git commit -a --file message.txt and then generating a patch file with git format-patch the commit message get written with all newlines stripped (Linux).
Seems like the culprit is the format-patch
By default, the subject of a single patch is "[PATCH] " followed by the concatenation of lines from the commit message up to the first blank line (see the DISCUSSION section of git-commit[1]).
I could not find yet the way to change this default behaviour. Is there a way?
How can I change it to take the commit message verbatim from the message.txt and put it into the generated 0001-xxx.patch file?
so from
* change 1
* change 2
it goes to
* change 1 * change 2
when running git format-patch and I obviously want it to keep the newlines.
This is how I am checking the result:
less message.txt
git commit -a --file message.txt
git format-patch -1 my_branch
less *.patch
To clarify and confirm, the git show shows the commit message with intact newlines. I am using Linux term.
EDIT: rewritten the question to reflect the format-patch at the core of the problem
EDIT2: I have found a workaround: in case there is an empty line after the first line in the message.txt the rest of the file format is preserved.
So this is how I have to format the message.txt
first line
empty line
* change 1
* change 2
With this I have solved my immediate problem but not sure if this is the right thing to do.