You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DiffPlug supports git core.eol, but does not support core.autocrlf #540
I'm developing on a Windows machine against a Unix repo, and have core.autocrlf=input set globally. My understanding based on #22 (comment) was that this was a supported scenario, without requiring further configuration.
Running spotless 3.18.0 on Gradle 5.0, spotless fails my build and appears to demand that I change line endings to \r\n.
I've tried explicitly setting lineEndings: 'GIT_ATTRIBUTES' (no change in behavior), and lineEndings: 'UNIX' (this works, but I'm not able to update every repo I have to work with).
We delegate to JGit for this, and the latest Spotless 3.27.2 uses JGit 5.5.0.201909110433-r. I know that JGit had a bug around core.autocrlf handling which was fixed at some point.
I haven't done the archaeology to lookup what version of JGit was in Spotless 3.18.0, but the first thing I would try is to update Spotless to latest and see if that fixes it. If it doesn't, then the next step is to see if there is any mention of core.autocrlf in the JGit changelogs from 5.5.0 until now.
I did find a bug related to Git for Windows' use of an additional git config file, although that wasn't what I was using. I've gone through git config --list --show-origin and added core.autocrlf=input to every source that isn't repo-specific. Here's what I now have:
changed the title [-]EOL problems using core.autocrlf=input[/-][+]DiffPlug supports git `core.eol`, but does not support `core.autocrlf`[/+]on Mar 17, 2020
The nice thing about core.eol is that it can take these three values, which are self-explanatory: lf, crlf, and native. The problem with core.autocrlf is that it can take these three values: true, input, and false, which are decidedly not self-explanatory.
It would be great to support core.autocrlf, it is definitely widely used. But it's not an easy fix, and there is an easy workaround, core.eol, which is imo a better-designed feature than autocrlf. Our documentation points people to the eol. Our PR you linked to falsely claims to fully support Git's line-ending behavior, but thanks to this issue it now loudly displays that autocrlf is not implemented.
I would love to merge a PR for this, but writing one will probably not make it to the top of my todo list.
That works perfectly, thanks. I'd skimmed that documentation and assumed it meant adding a .gitattributes to every repo, but as you say I can define core.eol in my Git config (I've done it at user level, as that seems to be the most clearly supported).
As autocrlf overrides this value, I'm actually even more confident that setting it won't break anything else.
It would be worth supporting autocrlf, I think, although with this workaround clearly documented it's less crucial. For example, the Git Extensions tool (pretty common in Windows environments) has configuration screens for line endings that write that setting behind the scenes.
Activity
nedtwigg commentedon Mar 16, 2020
We delegate to JGit for this, and the latest Spotless
3.27.2uses JGit5.5.0.201909110433-r. I know that JGit had a bug aroundcore.autocrlfhandling which was fixed at some point.I haven't done the archaeology to lookup what version of JGit was in Spotless
3.18.0, but the first thing I would try is to update Spotless to latest and see if that fixes it. If it doesn't, then the next step is to see if there is any mention ofcore.autocrlfin the JGit changelogs from5.5.0until now.jackwhelpton commentedon Mar 16, 2020
I've upgraded to 3.27.2 and see the same problem. As for JGit release notes, the only thing I turned up was:
5.6.0: Remove an old work-around for core.autocrlf = input
I don't know if that would help, to me it reads a bit like "autocrlf didn't used to work, now it does, so we no longer need this other code path".
jackwhelpton commentedon Mar 16, 2020
I did find a bug related to Git for Windows' use of an additional git config file, although that wasn't what I was using. I've gone through
git config --list --show-originand addedcore.autocrlf=inputto every source that isn't repo-specific. Here's what I now have:Unfortunately the behavior is still the same.
nedtwigg commentedon Mar 16, 2020
Can you try one more thing?
This will force your build to use the very latest git. If it still persists, then we'll have to file a bug with JGit.
jackwhelpton commentedon Mar 16, 2020
Same error, unfortunately: I definitely saw it pull down a fresh version of
jgitas part of that run too.[-]EOL problems using core.autocrlf=input[/-][+]DiffPlug supports git `core.eol`, but does not support `core.autocrlf`[/+]nedtwigg commentedon Mar 17, 2020
After digging in a bit more, I think this is a bug/missing-feature in Spotless, not JGit. Reading from https://git-scm.com/docs/gitattributes
But it looks like we don't respect that anywhere:
spotless/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java
Line 264 in 2204946
spotless/lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java
Line 278 in 2204946
The nice thing about
core.eolis that it can take these three values, which are self-explanatory:lf,crlf, andnative. The problem withcore.autocrlfis that it can take these three values:true,input, andfalse, which are decidedly not self-explanatory.It would be great to support
core.autocrlf, it is definitely widely used. But it's not an easy fix, and there is an easy workaround,core.eol, which is imo a better-designed feature thanautocrlf. Our documentation points people to theeol. Our PR you linked to falsely claims to fully support Git's line-ending behavior, but thanks to this issue it now loudly displays thatautocrlfis not implemented.I would love to merge a PR for this, but writing one will probably not make it to the top of my todo list.
jackwhelpton commentedon Mar 17, 2020
That works perfectly, thanks. I'd skimmed that documentation and assumed it meant adding a
.gitattributesto every repo, but as you say I can definecore.eolin my Git config (I've done it at user level, as that seems to be the most clearly supported).As
autocrlfoverrides this value, I'm actually even more confident that setting it won't break anything else.It would be worth supporting
autocrlf, I think, although with this workaround clearly documented it's less crucial. For example, the Git Extensions tool (pretty common in Windows environments) has configuration screens for line endings that write that setting behind the scenes.nedtwigg commentedon Feb 1, 2022
Fixed in
plugin-gradle 6.2.1andplugin-maven 2.20.1, thanks to @rweisleder!arulrajnet commentedon Mar 29, 2022
@nedtwigg This is broken in plugin-gradle >= 6.2.2.
Working in 6.2.1. I can reproduce this in my windows machine.
nedtwigg commentedon Mar 29, 2022
Thanks for bug report @arulrajnet. Must have been broken by #1119. Happy to merge a PR for this.
Fix diffplug#540
Fix git line ending handling (#540) which was broken by #1119 (#1158)