Conversation
Ensure *.sh and *.patch files are checked out with LF endings. This prevents CRLF-related execution failures inside Linux containers when developing on Windows. Signed-off-by: Dorin Geman <dorin.geman@docker.com>
There was a problem hiding this comment.
Code Review
This pull request adds a .gitattributes file to enforce LF line endings for *.sh and *.patch files, which is a good step to prevent cross-platform compatibility issues. However, this can be improved by applying the line ending normalization to all text files, not just specific extensions. This would make the configuration more robust and prevent similar issues with other file types in the future. I've added a suggestion to implement this.
| # Ensure shell scripts and patch files always use LF line endings. | ||
| # Required for correct execution in Linux containers; Windows may use CRLF. | ||
| *.sh text eol=lf | ||
| *.patch text eol=lf |
There was a problem hiding this comment.
While specifying line endings for *.sh and *.patch files is a good start, this line ending issue can affect many other text-based files in a cross-platform project (e.g., Makefile, Dockerfile, source code files). To create a more robust and future-proof solution, it's better to set a default rule for all text files.
Using * text=auto eol=lf will automatically handle line endings for all files that Git detects as text, which is a common best practice for repositories with contributors on different operating systems.
# Normalize all text files to use LF line endings.
# This prevents cross-platform issues with files like scripts, Makefiles,
# and Dockerfiles when working in mixed OS environments.
* text=auto eol=lf
ericcurtin
left a comment
There was a problem hiding this comment.
LGTM, which file had the CRLF line endings?
|
The shell script and the patches are checked out with CRLF by default in Git Bash. And I couldn't |
Ensure *.sh and *.patch files are checked out with LF endings. This prevents CRLF-related execution failures inside Linux containers when developing on Windows.
E.g.,