1

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

loop
  • 3,460
  • 5
  • 34
  • 57

1 Answers1

1

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.

d

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • In older versions of msysgit I could have multiple linefeeds. I checked my commit messages and I see a lot of my older commits have multiple linefeeds. Usually I am putting a little log output in a commit. Is there any git option to allow multiple linefeeds that I may have inadvertently disabled? – loop Aug 01 '12 at 00:24
  • @test I didn't see an option regarding linefeeds. Do you have example of those old commits on GitHub? – VonC Aug 01 '12 at 05:45
  • Sorry, no. It's definitely there though. I can see the multiple lines in my commits. – loop Aug 02 '12 at 06:39
  • @test ok, I will keep looking on my side, then. – VonC Aug 02 '12 at 06:41
  • 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! – loop Aug 07 '12 at 04:45
  • @test intereting. I have included your finding in the answer and will check the differences between then and now. – VonC Aug 07 '12 at 06:15
  • Regarding Git-1.7.7-preview20111014, when I author a commit in vi the multiple linefeeds are consolidated, but they are not if I commit a message in the Git GUI. Is that a clue as to what's happening? – loop Aug 09 '12 at 06:12
  • @test can you repeat that with the latest version of msysgit? – VonC Aug 09 '12 at 06:14
  • You know if you hadn't asked that I wouldn't have tested it because I'm almost certain that's how I had committed the first time and the linefeeds were consolidated. Incredibly, yes, I can repeat that with the version I have installed now -- Git-1.7.10-preview20120409 -- and the linefeeds are *not* consolidated in gitk. When I do `git commit --amend` on the message it will show the linefeeds as consolidated. Maybe sometimes they are consolidated and sometimes not? I don't know what's going on. Would you mind trying a commit with the Msys git GUI (whatever version) with the message in my OP? – loop Aug 09 '12 at 06:30
  • @test I have edited my answer to illustrate your point (tested with latest msysgit) – VonC Aug 09 '12 at 06:57
  • I've marked this as correct. If you wouldn't mind can you tell me what annotation software you are using for your screenshots? That's a nice collage. – loop Aug 10 '12 at 02:04
  • 1
    @test: you are not the first to ask ;) See the comments of http://meta.stackexchange.com/a/19775/6309 – VonC Aug 10 '12 at 05:33
  • The comments kind of lost me. You used faststone screen capture to make that? – loop Aug 10 '12 at 05:50
  • @test yes I did, as mentioned in http://stackoverflow.com/questions/3360596/eclipse-auto-build-after-save, http://stackoverflow.com/questions/506777/how-to-run-android-emulator-automatically-from-eclipse or http://stackoverflow.com/questions/2306880/how-can-i-install-eclipse-on-windows-7-64-bit. – VonC Aug 10 '12 at 05:54