Skip to content

Mixture of line endings #278

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

Open
coryschwartz opened this issue Feb 14, 2025 · 0 comments
Open

Mixture of line endings #278

coryschwartz opened this issue Feb 14, 2025 · 0 comments

Comments

@coryschwartz
Copy link

Yesterday, I submitted a PR and I struggled to make a succinct PR.

Although I was editing only a single line in a single file, my editor automatically re-wrote the entire file, adding Windows line endings too every line.

It turns out that this repo has a .editorconfig that mandates crlf line endings, but since most files do not have this line ending, editors that follow this file will automatically apply this change.

The reason this is a problem is that it makes it difficult to write small PRs that do not involve editing every line in the file.

Here is the offending line: https://github.com/go-oauth2/oauth2/blob/master/.editorconfig#L2

Steps to reproduce:

  1. Use an editor that abides by crlf line endings. (I'm using neovim v0.10.2)
  2. cat -A $(filename) to observe line endings
  3. Edit any of the many files that have Unix line endings. Add a single empty line, for example.
    1. git diff -- observe that every line in the entire file has been edited.

Observation

Most of the .go files have Unix line endings. Only four files actually adhere to the behavior expected in .editorconfig.

$ find . -name '*.go' -exec file "{}" ";" | grep -c "with CRLF line terminators"
4

My Recommendation

I think you should just remove the .editorconfig file. I can't think of any reason why it's needed. but if it is needed, then you should probably convert the files to have CRLF line endings.

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