Skip to content

Ensure that shell scripts and Dockerfiles use Unix line-endings #5949

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cowwoc
Copy link

@cowwoc cowwoc commented Apr 26, 2025

No description provided.

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on that link isn't it easier to just add core.autocrlf = input to your gitconfig?

.gitattributes Outdated
# Auto detect text files and perform LF normalization
* text=auto

*.sh eol=lf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only these files? We only use unix line-endings.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tonistiigi Because most other text files, like source-code, are expected to have CRLF line endings on Windows.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @tonistiigi — enforcing LF consistently is important.

I usually work in teams with a mix of Windows and Linux devs, and setting the following helps avoid cross-platform line-ending issues:

In .gitattributes:

* text = lf

And in .editorconfig:

root = true

[*]
end_of_line = lf


This makes sure both Git and editors enforce LF, which avoids diffs from accidental CRLF on Windows. This ensures editors (like VS Code, IntelliJ, etc.) also respect LF line endings, regardless of local defaults.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I read, not all Windows editors support LF endings but you're right that all the major coding editors certainly do.

I'm fine with defaulting to LF endings if you guys prefer. Let me know if you want me to update the PR accordingly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change it to lf for all text files if we want to get this in.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Try now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexgwolff PTAL

@cowwoc Please squash commits as well.

Signed-off-by: Gili Tzabari <cowwoc2020@gmail.com>
@cowwoc cowwoc force-pushed the added-gitattributes branch from e5bce49 to 4c48984 Compare May 4, 2025 01:16
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.

3 participants