Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit message line endings modified by commit dialog #5908

Closed
Deadlock39 opened this issue Dec 13, 2018 · 33 comments · Fixed by #6877

Comments

@Deadlock39
Copy link

commented Dec 13, 2018

I am experiencing a bug/regression with 3.0

When I create a commit using the commit dialog, line endings appear to be getting removed, or converted from Windows (CRLF) to Unix (LF). I haven't been able to confirm which of these is the actual cause, but the result is that all the commit message lines appear to be squashed into one line in the commit message after the commit has completed.

This occasionally does not occur on my initial commit made from a commit template. It always seems to occur if I amend a commit by bringing up the previous commit message via the drop down menu.

Environment

  • GitExtensions version: 3.00.00.4433
  • GIT version: 2.12.2.windows.2
  • OS version: Microsoft Windows NT 10.0.16299.0
  • .NET version: 4.7.3221.0

This was not happening with version 2.51 prior to upgrading to 3.0.

@drewnoakes

This comment has been minimized.

Copy link
Member

commented Dec 13, 2018

Can you share a screenshot of the problem that occurs after you commit? I am hoping this is just a presentation issue.

@Deadlock39

This comment has been minimized.

Copy link
Author

commented Dec 13, 2018

The title and description appear squashed in the commit view of the main window after this occurs.

git-extensions-commitmsg1

They also appear squashed in the commit dialog after bringing the message up from the history drop down.

git-extensions-commitmsg2

My changes go through Gerrit for review as well, and the message appears less squashed there, but the blank line between the title and description is gone.

git-extensions-commitmsg3

I have a commit hook that adds the Change-Id seen in these images, which is not affected by this issue, but the Change-Id line gets collapsed into the first line as well if I amend the commit.

@Deadlock39

This comment has been minimized.

Copy link
Author

commented Dec 13, 2018

In some cases, it seems to work normally after my initial commit:

git-extensions-commitmsg4
Result:
git-extensions-commitmsg5

After amending, it always seems to do this:
git-extensions-commitmsg6
Result:
git-extensions-commitmsg7

@vbjay

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

Provide the output of the following commands in git bash in the repo showing this issue

git config core.autocrlf
cat .gitattributes
@vbjay

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

@Deadlock39

This comment has been minimized.

Copy link
Author

commented Dec 13, 2018

git config core.autocrlf: true
cat .gitattributes: cat: .gitattributes: No such file or directory

This doesn't seem to be related to a git setting. The issue did not occur prior to my upgrade from 2.51 to 3.0 this morning. Also, disabling the "Compose commit messages in the Commit dialog"setting, and editing my commit messages external to git-extentsions prevents this issue from occurring.

@vbjay

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

Does it happen without your hook?

@vbjay

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

I would add debugging code to your hook that lets you see the difference between a regular commit and an amend. Have it write out the message to a file in the .git folder that is regular_commit and regular_commitMOD and amend_commit and amend_commitMOD. Look at the before and after your hook modifies.

@Deadlock39

This comment has been minimized.

Copy link
Author

commented Dec 13, 2018

I'm attempting to disable the hook now to determine if it is contributing to the issue.

@Deadlock39

This comment has been minimized.

Copy link
Author

commented Dec 13, 2018

I removed my commit hook, and was still able to reproduce the behavior when amending.

On initial commit there is also a commit template that I have configured. I have attempted to disable that, but have not succeeded yet.

After initial commit, the COMMIT_EDITMSG file looks like this:

test[LF]
[LF]
test[LF]
test[LF]

After amending the blank line is removed.

If I disable the Commit Dialog, the commit message is opened in word pad after clicking the commit button. After saving there, the COMMIT_EDITMSG file looks like this:

test[CR][LF]
[CR][LF]
test[CR][LF]
test[CR][LF]

@vbjay

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

Initial commit
image

    line 1

    line 3
    line 4

    line 6

Amend not changing the commit message
image

    line 1                                         
                                                   
    line 3                                         
    line 4                                         
                                                   
    line 6                                         
@drewnoakes

This comment has been minimized.

Copy link
Member

commented Dec 13, 2018

Can you reproduce this from the command line?

If you construct a file with specific line endings for the message, then use

git commit --file="commitmessage.txt"

Then you can print out the contents of the commit as git sees it directly using

git cat-file commit `git rev-parse HEAD`

If everything goes well there, you can compare what you see on the command line with what Git Extensions sees when it runs git commands using the Command Log in the Tools menu.

@Deadlock39

This comment has been minimized.

Copy link
Author

commented Dec 13, 2018

I had not thought to check out the command dialog. I can see a bit more detail from there.

I ran the amend here:
git-extensions-commitmsg8

Prior to closing the console dialog, the COMMITMESSAGE file is still in the .git folder, and looks like this:
git-extensions-commitmsg9

The blank line appears to have been dropped from this temporary file (created by the Commit Dialog I assume?) prior to the commit being performed in git at all. As soon as I close the console, the temporary COMMITMESSAGE file is removed.

@drewnoakes

This comment has been minimized.

Copy link
Member

commented Dec 13, 2018

Here's what happens on my PC:

image

image

image

It looks like I'm getting your newline 🤣 Why do I have an extra one?

The amend setting doesn't seem to make a difference.

@vbjay

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

@jamez613

This comment has been minimized.

Copy link

commented Dec 19, 2018

I'm seeing the exact same issue as @Deadlock39 since upgrading to 3.0

@RussKie

This comment has been minimized.

Copy link
Member

commented Dec 19, 2018

@drewnoakes

This comment has been minimized.

Copy link
Member

commented Dec 19, 2018

@jamez613 if you could go to the "Help > About" menu, then click the button that copies information about your computer to the clipboard and paste it here, it would be useful.

Please also have a think whether there's anything else that's unique about your environment, and include that here.

@jamez613

This comment has been minimized.

Copy link

commented Dec 20, 2018

  • Git Extensions 3.00.00.4433
  • Build fca7cf2
  • Git 2.20.1.windows.1
  • Microsoft Windows NT 10.0.17134.0
  • .NET Framework 4.7.3221.0
  • DPI 96dpi (no scaling)

git config core.autocrlf: true

I also have a commit hook that adds the Change-Id, and I also push to Gerrit. I'm not sure how to disable the commit hook though..?

@vbjay

This comment has been minimized.

Copy link
Contributor

commented Dec 21, 2018

@jamez613

This comment has been minimized.

Copy link

commented Dec 21, 2018

Interesting, it does seem to be caused by some interaction with https://www.gerritcodereview.com/cmd-hook-commit-msg.html, if I disable the hook ammend works correctly.

I've been using this hook with GitExtensions for years though and it always worked prior to 3.0

@jamez613

This comment has been minimized.

Copy link

commented Dec 21, 2018

Hmm, I spoke too soon - just reproduced it again with the hook still disabled

@RussKie

This comment has been minimized.

Copy link
Member

commented Dec 21, 2018

@jamez613 could you please grab the portable build from v2.51.05 and try it side by side?

@jamez613

This comment has been minimized.

Copy link

commented Dec 21, 2018

2.51.05 works fine for me

@RussKie

This comment has been minimized.

Copy link
Member

commented Dec 28, 2018

That's just got more interesting... 😮

@jrhall-mchp

This comment has been minimized.

Copy link

commented Jan 2, 2019

I am also having the same issue with v3.00. Tried the portable build from v2.51.05 and it does not exhibits the issue.

  • Git Extensions 3.00.00.4433
  • Build fca7cf2
  • Git 2.20.1.windows.1
  • Microsoft Windows NT 10.0.17763.0
  • .NET Framework 4.7.3260.0
  • DPI 96dpi (no scaling)
@vbjay

This comment has been minimized.

Copy link
Contributor

commented Jan 2, 2019

Screenshot this window
image

image

@jrhall-mchp

This comment has been minimized.

Copy link

commented Jan 2, 2019

image

@BaronZemo

This comment has been minimized.

Copy link

commented Feb 18, 2019

I have an issue that I think is related to this one. My newlines get stripped completely from the commit message. It doesn't happen every time. I haven't quite figured out what the common factor is. Here's my info:

  • Git Extensions 3.0.2.5232
  • Build 23b6f51
  • Git 2.19.1.windows.1
  • Microsoft Windows NT 6.1.7601 Service Pack 1
  • .NET Framework 4.7.3324.0
  • DPI 96dpi (no scaling)
@RussKie

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

If you could work out a pattern, it would help in tracing the issue down

@BaronZemo

This comment has been minimized.

Copy link

commented Feb 19, 2019

I've noticed two different patterns.

  1. If I have to stage files during/after typing up my commit message. There's two ways to make this happen.
    1a) If I forget to stage my files before pressing the commit button. Git Extensions will tell me I don't have any staged files and asks if I want to stage them/it, then I say yes, then it commits.
    1b) I have a pre-commit hook that will scan the files I'm trying to merge for a copyright date. If my date is not current, the script will update the files, then I have to stage those changes.
  2. It appears that if I am amending a commit message, the newlines consistently get stripped. I select the previous message from a drop down list, modify message, then commit with the Amend box checked. This consistently removes thew newlines.
@bsruth

This comment has been minimized.

Copy link

commented Apr 23, 2019

I think there was a regression in this commit: ababaff

This change now skips all empty lines. I haven't found a root cause for the newlines being eaten (I think it has something to do with a post-processing script we run). But am planning on submitting a fix that is working for my use case.

@RussKie

This comment has been minimized.

Copy link
Member

commented Apr 28, 2019

Thanks, looking forward to it

bsruth added a commit to bsruth/gitextensions that referenced this issue May 8, 2019
…ue where commit messages can have the newlines eaten when a commit template is used.

Issue: gitextensions#5908
@mstv mstv added this to the 3.2.0 milestone Jun 29, 2019
@mstv mstv closed this in #6877 Jun 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.