EFForg / privacybadger

Privacy Badger is a browser extension that automatically learns to block invisible trackers.
https://privacybadger.org
Other
3.16k stars 382 forks source link

`.editorconfig` specifies `lf` line-endings, but there is no matching `.gitattributes` #2946

Open Mikaela opened 8 months ago

Mikaela commented 8 months ago

I happened to notice that multiple Privacy Badger related repositories have a .editorconfig which specifies end_of_line = lf. However it's possible that individual contributors have git configured to checkout as crlf (core.autocrlf) especially in Windows, which may confuse editorconfig capable text editors.

The solution would be adding a .gitattributes file with contents * text=auto eol=lf so git would always check-out the repository with lf line-endings even on Windows regardless of the contributors git configuration as .gitattributes takes priority. Optionally a git add --renormalize . would ensure that all text files are checked into the repository with lf line endings.

See https://git-scm.com/docs/gitattributes#_end_of_line_conversion

I think this would also decrease the chance of https://github.com/EFForg/dnt-policy/issues/22 happening at least when the repository is cloned with git.

I opened this issue instead of a PR, because in addition to being unsure of whether this is considered a problem, I think opening identical pull requests towards multiple repositories would be considered as spam especially out of the blue without any explanation.

ghostwords commented 8 months ago

Thanks for raising this issue and thank you for your thoughtfulness!

However it's possible that individual contributors have git configured to checkout as crlf (core.autocrlf) especially in Windows, which may confuse editorconfig capable text editors.

What will happen in this scenario? I'm trying to understand the problem.

Mikaela commented 8 months ago

I don't know how intelligent text editors are, but I think showing line endings in wrong way is a possibility or maybe they would write mixed crlf and lf line endings onto the file.

I think the worst case scenario would be git diff claiming that every line was removed and then added again. I was trying to find a link that would demonstrate the issue, but I didn't find an exact case while these seem the most relevant:

ghostwords commented 8 months ago

Got it, thanks!

I also got a bit more context by visiting some high profile EditorConfig users. Looks like having a well-configured .gitattributes file is best practice if your project wants to support Windows contributors.