1
0

add .gitattributes file for end-of-line normalisation

This should prevent accidentally committing files with CRLF line endings to the repo.

related: https://github.com/spesmilo/electrum/issues/8025

see https://git-scm.com/docs/gitattributes#_end_of_line_conversion :
> If you want to ensure that text files that any contributor introduces to the repository have their line endings normalized, you can set the text attribute to "auto" for all files.
> ```
> * text=auto
> ```
>
> From a clean working directory:
> $ echo "* text=auto" >.gitattributes
> $ git add --renormalize .
> $ git status    # Show files that will be normalized
> $ git commit -m "Introduce end-of-line normalization"

-----

I have tried to find some large cross-platform projects that use git for EOL normalisation.
Notably the golang/go project recommends against it, but the others have it in some form:

4ec9ed8fde/.gitattributes
160bb0e66b/.gitattributes
7fda097623/.gitattributes
103a5c98b8/.gitattributes
0990046d8d/.gitattributes
1c2dc79f51/.gitattributes
0d65a985b9/.gitattributes
d3bafb8b6e/.gitattributes
This commit is contained in:
SomberNight
2022-10-20 19:49:49 +00:00
parent c5d17183f7
commit 2089f06ffa

12
.gitattributes vendored Normal file
View File

@@ -0,0 +1,12 @@
# Auto detect text files and perform end-of-line normalization (to LF)
* text=auto
# These Windows files should have CRLF line endings in checkout
*.bat text eol=crlf
*.ps1 text eol=crlf
# Never perform LF normalization on these files
*.ico binary
*.jar binary
*.png binary
*.zip binary