gitattributes: normalise all text files to LF - #553
Merged
Conversation
The MinGW CI build stamped every Windows binary as "<version>-modified" even
on a pristine checkout. Cause, reproduced on a Windows 11 + MSYS2 box:
Git for Windows core.autocrlf = true (its own system gitconfig)
MSYS2 git core.autocrlf = unset -> false
actions/checkout runs under Git for Windows and writes CRLF; the build then
reads the tree with MSYS2 git, which expects LF. Files covered by an
extension rule were fine, but 14 were not matched by any pattern and showed
up permanently modified:
i/lf w/crlf attr/ .clang-format
i/lf w/crlf attr/ debian/rules
Note the empty attr/ column. The gaps were dotfiles, extensionless files,
debian/*, *.rc, *.spec, *.sh, and lib/version.h.in (which *.h does not
match). Listing extensions cannot close this class of gap -- the next
unlisted file type reopens it -- so replace the list with a catch-all.
The catch-all must come first, because git applies the last matching pattern
per attribute and the binary declarations need to override it. Verified:
assets/headsetcontrol.{ico,png} still resolve to text=unset binary=set, and
`git add --renormalize .` rewrites no blob, since every file was already LF
in the index.
Besides CI, this also fixes the same false-dirty state for anyone developing
on Windows.
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.
The MinGW CI build stamped every Windows binary as "-modified" even on a pristine checkout. Cause, reproduced on a Windows 11 + MSYS2 box:
Git for Windows core.autocrlf = true (its own system gitconfig)
MSYS2 git core.autocrlf = unset -> false
actions/checkout runs under Git for Windows and writes CRLF; the build then reads the tree with MSYS2 git, which expects LF. Files covered by an extension rule were fine, but 14 were not matched by any pattern and showed up permanently modified:
i/lf w/crlf attr/ .clang-format
i/lf w/crlf attr/ debian/rules
Note the empty attr/ column. The gaps were dotfiles, extensionless files, debian/*, *.rc, *.spec, *.sh, and lib/version.h.in (which *.h does not match). Listing extensions cannot close this class of gap -- the next unlisted file type reopens it -- so replace the list with a catch-all.
The catch-all must come first, because git applies the last matching pattern per attribute and the binary declarations need to override it. Verified: assets/headsetcontrol.{ico,png} still resolve to text=unset binary=set, and
git add --renormalize .rewrites no blob, since every file was already LF in the index.Besides CI, this also fixes the same false-dirty state for anyone developing on Windows.