[FIX] Add .gitattributes so POSIX scripts stay LF on Windows clones - #2346
Open
pranayr710 wants to merge 1 commit into
Open
pranayr710 wants to merge 1 commit into
pranayr710 wants to merge 1 commit into
Conversation
Git for Windows defaults to core.autocrlf=true, which rewrites LF to CRLF
on checkout. The tree has no .gitattributes, so nothing stops that from
reaching the shebang of every POSIX script, and a clone made on Windows
cannot run the build documented in docs/COMPILATION.MD or the
local-source Docker build in docker/README.md:
$ ./pre-build.sh
/usr/bin/env: 'bash\r': No such file or directory
exit=127
Pin the shell scripts to LF, and the Windows batch/PowerShell scripts to
CRLF, on every platform.
Deliberately narrow: no "* text=auto". 978 tracked files are committed
with CRLF and normalising them would be a repo-wide rewrite unrelated to
this fix. Verified that adding this file changes no tracked content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2345
Reason for this PR:
Sanity check:
What was wrong
There is no
.gitattributesin the tree. Git for Windows defaults tocore.autocrlf=true, so a clone made on Windows gets CRLF in every text file — including the shebang of all 16 POSIX shell scripts.docker/DockerfilerunsRUN ./pre-build.sh, and that fails:CONTRIBUTING.mdasks for "Unix line endings" but nothing enforces it.Before / after
Clone with Git's default Windows setting, then run the project's own pre-build step under Linux:
linux/pre-build.sh./pre-build.shmasterScope
Deliberately narrow — no
* text=auto. 978 tracked files are currently committed with CRLF (Visual Studio project files and similar), so a blanket rule would renormalise the whole repo and bury this fix in noise. The rules here name only POSIX scripts (eol=lf) and Windows scripts (eol=crlf).I verified with
git add --renormalize .that adding this file changes no tracked file's content: the commit is the new file and nothing else.The
*.bat/*.ps1lines are the mirror case and are a no-op today (those files are already CRLF); they are there so the inverse problem cannot appear later. Happy to drop them if you'd rather keep the file to the LF half.