lol

.gitattributes: manage CRLF handling (#424336)

In certain circumstances, Git will munge line endings when it checks out
and commits files. This can result in difficult-to-debug errors when
files are changed when they're checked out. To avoid that problem, set
.gitattributes such that Git will always use LF line endings for files
it detects as text files.

*.diff and *.patch files are excluded, as committed patch files may need
to patch upstream source code that intentionally uses CRLF line endings.

Fixes #423762

authored by

Adam Dinwoodie and committed by
GitHub
c17d64d6 e98015f0

+25
+25
.gitattributes
··· 18 18 # pkgs/top-level/all-packages.nix merge=union 19 19 20 20 ci/OWNERS linguist-language=CODEOWNERS 21 + 22 + # Avoid munging line endings when using Git for Windows, and instead keep files 23 + # using LF line endings. This particularly affects scripts committed in the 24 + # nixpkgs repository. 25 + # 26 + # - `text` without `=auto` would mean "Git should always munge line endings on 27 + # this file so there will never be a CRLF in the repository, and the line 28 + # endings in the working directory should respect the local Git 29 + # configuration." 30 + # - `text=auto` means "Git should try to work out if this file is a text file. 31 + # If it is, it should do the line-ending munging as for `text`, and if it 32 + # isn't, it should leave the file alone." 33 + # - `eol=lf` means "Ignore any local configuration about how line 34 + # endings normally work on this platform. This file should always and only 35 + # have LF line endings in the repo (so if there's a CR in the repo, it's 36 + # meant to be there in addition to any end-of-line mark), and the selected 37 + # attribute is how the file should appear in the working directory." 38 + # 39 + # See https://github.com/NixOS/nixpkgs/issues/423762 for historical context. 40 + * text=auto eol=lf 41 + 42 + # Don't force LF line endings for diff/patch files, as they might be correctly 43 + # patching CRLF line endings from an upstream source package. 44 + *.diff !text !eol 45 + *.patch !text !eol