-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Try now.
There was a problem hiding this comment.
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>
e5bce49
to
4c48984
Compare
No description provided.