Spotless converting newlines to CRLF

Spotless always converts the newlines to CRLF in my environment, very annoying -.- Does somebody know how to solve this?

Git core.autocrlf is set to input, although changing it to other values does not affect the behavior. I also tried to add eol=lf to the .gitattributes file, but without any success…

What platform are you using?

Windows 10, IntelliJ IDEA

I have the same problem, had to set core.autocrlf=true to make it work.

Spotless doesn’t properly support autocrlf, so it’ll think that crlf is correct if the os is detected as windows. You can try setting core.eol=lf, the .gitattributes setting is ignored on my system (Win 10), don’t know why. In fact I have to set core.eol=crlf to do a complete build (see https://github.com/openhab/openhab-addons/issues/8712)

But why do you want to use lf on a windows machine?

I don’t know a single text editor that does not support LF (even WordPad and Notepad do support it meanwhile!) and I’d like to checkout the code always as-is, e.g. to detect issues with newline format within the remote repository (not necessarily for openHAB, but in general for any projects).

Did you try core.eol=lf?

1 Like

Ah, that works, thanks! Didn’t try that as the Git docs said it’s overriden by autcrlf.

That’s why it works flawlessly with the opposite (core.eol=crlf) on my system. autorlf=true takes precedence when git is checking what to do, but since spotless does not implement autocrlf it takes the value of eol.

1 Like