Skip to content
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

Make Git EOL consistent with .editorconfig (LF) #2230

Closed
wants to merge 1 commit into from

Conversation

sharpjs
Copy link
Contributor

@sharpjs sharpjs commented Mar 10, 2024

This was resubmitted as #2231.

What was here before

What's In This PR

The .editorconfig file sets end_of_line = lf, but .gitattributes does not. This leaves Git to behave as per its own configuration or defaults. On Windows, it is very common (and IMO, best practice) to enable the autocrlf feature to perform EOL normalization, which transforms LF to CRLF on checkout and performs the inverse transformation on commit. For Iosevka, however, the result is that a fresh git clone consists of files with CRLFs, in contravention of the .editorconfig.

One consequence is that a Windows user following the Docker build instructions can generate a container image whose build.sh contains CRLFs, which Bash does not understand. This results in containerized Iosevka builds failing with a rather cryptic error:

image

Another consequence is that tools that understand .editorconfig might complain about inconsistent line endings and convert the CRLFs to LFs on save, generating seemingly spurious changes in git status.

A few Git commands fix this, but an easier way is to ensure that Git checks out using LF regardless of the developer's platform or Git configuration. This PR does that.

An Alternative Way

A slightly more complicated way would be to enable Git EOL normalization everywhere except for the one file that must use LF. Doing so would enable Windows users to use CRLF while everyone else (and the repository itself) remains using LF. This is the choice I make for my own repositories if the build tools support both LF and CRLF. If you'd prefer this, I am happy to change the PR.

.editorconfig

First, remove the line end_of_line = lf.
Then add:

[/docker/*.sh]
end_of_line = lf

.gitattributes

Add:

# Autodetect text files and perform EOL normalization
* text=auto

# Bash understands LF only
/docker/*.sh text eol=lf

Copy link

Your PR was set to target main or prerelease.
PRs should be target dev instead.

@sharpjs
Copy link
Contributor Author

sharpjs commented Mar 10, 2024

I will resubmit targeting dev. Edit: #2231

@sharpjs sharpjs closed this Mar 10, 2024
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

Successfully merging this pull request may close these issues.

1 participant