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

Reformatting on Windows during pre commit hook causes the reformatted file to be restaged #227

Open
mjuergens-cg opened this issue Jul 17, 2024 · 1 comment

Comments

@mjuergens-cg
Copy link

mjuergens-cg commented Jul 17, 2024

What steps will reproduce the problem?
Steps to reproduce the behavior:

  1. Git repo on Windows with autocrlf=true
  2. git-code-format-maven-plugin in 5.3 set up using Maven, Git hooks installed
  3. Change a file in the repo such that git-code-format-maven-plugin will reformat it
  4. Commit

What is the expected output?
Commited, nothing more

What happens instead?
git status show that the file is restaged (this time apparently due to changed line endings):

modified: src/x/y.java

I can see the original file has CRLF line endings, the temporary file has LF line endings and the restaged file has CRLF endings again.

When I recommit again the staged file (that is not to be reformatted then), the commit is successful without being restaged.

Environment:

  • OS: Windows 10
  • Git version: 2.39.1
  • git-code-format-maven-plugin version: 5.3
  • Maven version: 3.9.5

Link to a git repository that can be cloned to reproduce the problem:

Additional context
No problems when autocrlf=false

@mjuergens-cg
Copy link
Author

Probably a duplicate of #96 - sorry :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant