fix: Ensure committed files are normalized to LF #361
Merged
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.
This avoids accidentally committing files with CRLF line endings which
rustfmt
will happily normalize to LF creating a very noisy diff from these invisibles.Additional context
As I'm presently developing from Windows with VSCode and I haven't adjusted defaults yet, when I create new files they default to CRLF for line endings.
I was only aware of this after running
rustfmt
and noticing every single line had been changed in the diff, even though there was no visual difference the invisibles change from CRLF to LF was the cause (_since I had already committed this file quite a while ago with CRLF before runningrustfmt
..gitattributes
is a useful file to prevent that sort of mistake from occurring as the project gains more contributors. It also helps ensure better compatibility when certain files should be checked out with LF or CRLF specifically, which I've added a contextual comment for the maintainers benefit.Dockerfile
can be one of the cases where you want to ensure LF is used as checkout, sincedocker build
can failRUN
directives under some contexts (as I have experienced in the past):Likewise for any scripts like
.sh
relying on the shebang to be executed that are added to the image viaCOPY
, since the shebang line would have CRLF in environments that default to that otherwise withouteol=lf
. Similar for.bat
which should useeol=crlf
.Dockerfile-cuda-all
was renamed to a more conventionalDockerfile.cuda-all
.Most editors will better recognize
Dockerfile.*
or*.Dockerfile
(which Dockers official docs suggest as convention). I went withDockerfile.
as a prefix for better co-location, similar to what the repo is already doing.