Skip to content

Incorrect Handling of Partial Stage/Discard with autocrlf Set to False #1995

@Piolie

Description

@Piolie

Steps to Reproduce

  1. Initialize a new Git repository and set the core.autocrlf configuration to false:
git init
git config core.autocrlf false
  1. Create a new text document with the following contents, ensuring it uses Windows-style line endings (CRLF):
test1



test3

  1. Stage and commit the initial version of the file:
git add *
git commit -m 'first commit'
  1. Modify the text file to the following, replacing the line between test1 and test3:
test1

test2

test3

Open sourcegit. Ensure the right panel displays changes (with Ignore Whitespace Changes disabled):

Image
  1. Stage the hunk (Ctrl+S) and observe that something is staged, but an un-stageable hunk remains visible in the right panel:
Image
  1. Now run the following commands to commit the staged change and reset the un-stageable one:
git commit -m 'second commit'
git reset --hard
  1. Check the text file. You should see that the modified line now has a Linux-style EOL character (LF).

Expected Behavior

The line endings remain consistent with the original Windows-style CRLF after setting autocrlf = false, even when making partial stages and discards.

Actual Behavior

The line endings are converted to Linux-style LF when the changes are staged, instead of retaining the original CRLF.

I checked and everything works as expected when the text file contains only LF EOLs.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions