Reputation: 3590
I'm using msys git and one thing I've noticed is that when I am in vi and I write a commit message that contains two or more linefeeds that when it is actually committed there will only be a single linefeed.
If I write this:
my first commit
Hello out there from the first line.
Hello out there from two linefeeds below.
It will be committed as:
my first commit
Hello out there from the first line.
Hello out there from two linefeeds below.
Does anyone using msys git notice this and how can I stop it from happening?
git version 1.7.10.msysgit.1
Thanks
Upvotes: 1
Views: 182
Reputation: 1323065
If you look at pretty.c
(in charge of format_commit_item()
function), it seems that is the norm for commit messages.
The first empty line is for separating the header from the body of the commit message.
All other linefeeds are grouped into no more than one empty line, probably because those commits can be send in email, and the reviewers don't wish to see the newlines used and abused, making said emails excessively long to scroll through.
The OP test confirms this used to be possible in previous versions of msysgit:
Alright I did some testing in a VM and found Git-1.7.7-preview20111014.exe if I install it and then goto Git GUI and open my repo and I file a commit, I can make multiple linefeeds without the consolidation.
I wish they'd bring that back, I need it! –
Now, Git-1.7.7-preview20111014 means commit 81143a87 (2011-10-14T06:04:08-07:00), which means pretty.c
was in that state (commit f67d2e82d6).
Since then, it (pretty.c
) has evolved mainly to parse the commit signature, without visible effect on the format_commit_item()
function.
I confirm another OP's finding:
Even with the latest msysgit (PortableGit-1.7.11-preview20120710), a commit edited in the git gui will keep its linefeeds.
A commit edited in vi will not.
You can see that the initial message commit only keep one newline per comment.
I have to amend it in the git gui in order to put (and keep after commit) multiple newlines.
Upvotes: 1