Browse Source

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
patch-4
SomberNight 2 years ago
parent
commit
2089f06ffa
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 12
      .gitattributes

12
.gitattributes

@ -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
Loading…
Cancel
Save