Skip to content

Fix line endings of mwnw.cmd - #7154

Merged
adangel merged 1 commit into
pmd:mainfrom
UncleOwen:fix-line-endings
Oct 6, 2026
Merged

adangel merged 1 commit into
pmd:mainfrom
UncleOwen:fix-line-endings

Conversation

@UncleOwen

Copy link
Copy Markdown
Member

Describe the PR

The latest dependabot update for maven changed the line endings of mvnw.cmd to Unix line endings, even though it is a Windows file - and correctly declared as such in .gitattributes.

This commit changes the line endings back to Windows format.

See dependabot/dependabot-core#8693 for the depend-a-bot issue.

See #7140 for the offending PR that introduced the wrong line endings

Related issues

  • None

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

The latest dependabot update for maven changed the line endings of
mvnw.cmd to Unix line endings, even though it is a Windows file - and
correctly declared as such in .gitattributes.

This commit changes the line endings back to Windows format.

See dependabot/dependabot-core#8693
for the depend-a-bot issue.

See pmd#7140
for the offending PR that introduced the wrong line endings
@pmd-actions-helper

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-10-06 13:08:27+00:00 for 74e9549)

@UncleOwen
UncleOwen requested a review from zbynek October 6, 2026 14:49
@adangel adangel added this to the 7.29.0 milestone Oct 6, 2026
@adangel adangel added the in:pmd-internals Affects PMD's internals label Oct 6, 2026

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@adangel
adangel merged commit 1f9b1d3 into pmd:main Oct 6, 2026
13 checks passed
@adangel

adangel commented Oct 6, 2026

Copy link
Copy Markdown
Member

If you having trouble updating your main branch:

  • comment out the line in .gitattributes about mvnw.cmd
  • git restore mvnw.cmd
  • merge origin/main
  • git restore .gitattributes

Since mvnw.cmd is always modified locally, and origin/main also modifies the file...

@UncleOwen
UncleOwen deleted the fix-line-endings branch October 6, 2026 17:42
@adangel

adangel commented Oct 6, 2026

Copy link
Copy Markdown
Member

Actually, I think what happened here is:

  • we have .gitattributes configured for mvnw.cmd with eol=crlf
  • git stores the file in repository normalized as "lf" and checks out as "crlf" (is this true?)
  • the dependabot PR stored the file as "crlf"
  • for some reason, changing "crlf" to "crlf" makes the file dirty

At least, in my other repo https://github.com/adangel/summit-ast where the same dependabot PR landed, I committed the file wrongly as "lf" and the dependabot PR fixed it correctly to be "crlf" - but I have no .gitattributes there.

@UncleOwen

Copy link
Copy Markdown
Member Author

I don't think git doesn't normalizes anything (unless told so by .gitattributes)

@adangel

adangel commented Oct 8, 2026

Copy link
Copy Markdown
Member

Same happened here: pmd/build-tools#200 (which has a .gitattributes)

With git ls-files --eol mvnw.cmd you can see, how the file is stored.

On main branch:
i/lf w/crlf attr/text eol=crlf mvnw.cmd

Stored in index as lf (i/lf), in the checked out working tree crlf (w/crlf).

In the branch that dependabot created it is:

i/crlf w/crlf attr/text eol=crlf mvnw.cmd

So, dependabot changed it to crlf for storage. Since we have the text attribute, git will always normalize it to lf and then add crlf in the working tree, marking this file dirty.

I've now run git add --renormalize mvnw.cmd, which stored it as we declared it in .gitattributes.

We could store it as crlf in the repo, but then, if someone edits this file with an editor that doesn't preserve lineendings, it could be easily broken (Windows CMD requires crlf). That's why we added the .gitattributes, so that no matter what the editor does, it is stored normalized in the git repo and on checkout it will have crlf line endings.

adangel added a commit that referenced this pull request Nov 19, 2026
We no longer normalize the line endings to lf in git storage and to crlf
on checkout (-text).
When dependabot updates this file, it will always store it with crlf (without
using .gitattributes settings) and the file would appear always as modified.
Since the file is usually not edited manually but only by wrapper:wrapper or
dependabot, it's only a small risk that someone accidentally modifies the
line endings to lf by manually editing the file.

Same problem was previous addressed in #7154.
Problematic PRs: #7140 #7359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:pmd-internals Affects PMD's internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants