Check out text files with LF on every platform

Merged
PA
1d ago
+6-0

Problem

Git for Windows installs with core.autocrlf=true, so a fresh clone checks every text file out with CRLF. .gitattributes pins only *.sh to LF, while .prettierrc.json sets "endOfLine": "lf". On such a clone of main at 9dfebdd:

  • prettier rejects 102 of the files under web/*.js and tests/browser/*.js, so the pre-commit hook refuses any commit that stages a web file. The hook checks a git checkout-index copy of the index, and that checkout applies autocrlf too, so even content stored as LF fails there.
  • npm test fails 33 more tests than on an LF checkout, the ones that read source text with patterns that do not expect \r, such as "the module state the first paint reads exists before init paints" and "the gutter is rebuilt only when the line count moves".

Change

* text=auto eol=lf at the top of .gitattributes checks every text file out with LF whatever core.autocrlf says. The later lines still override it for the paths they name, so web/vendor/** keeps -text and its hashed bytes stay untouched. git add --renormalize . stages nothing but .gitattributes itself: every text file is already stored as LF, so no content changes.

Test

Two fresh worktrees checked out with git -c core.autocrlf=true, on Windows 11 with Git for Windows and Node 24.20.0:

main at 9dfebddthis branch
files checked out with CRLF6490
JS files prettier rejects1020
npm test failures12794

The 33 tests that stop failing are all ones that read source text, and no test fails on the branch that passes on main. None of the 94 that remain is about line endings: they need vendored assets the worktree has not fetched or a C++ compiler with -std=c++20, or they are the four tests #322 reports. Staging a one-line comment in web/lib.js and committing fails the pre-commit hook on main with "Code style issues found" and passes its staged checks on this branch. The Rust lanes of ./scripts/test.sh were not run.

This is separate from #322 and #323, which fix the four tests that pass an absolute Windows path to import(); that failure happens with LF too.


Summary by cubic

Pins every text file to LF in the working tree so Windows clones, where Git for Windows defaults core.autocrlf to true, get the same line endings as everywhere else. The new * text=auto eol=lf line at the top of .gitattributes overrides that default; later lines still win for the paths they name, so web/vendor/** keeps -text and its hashed bytes stay untouched.

  • Fixes the pre-commit hook on fresh Windows clones, where prettier rejected all JS files because .prettierrc.json asks for LF, blocking any commit touching web/.
  • Resolves failures in tests that read source text and tripped over \r.
  • The repository already stores every text file as LF, so no file content changes beyond .gitattributes itself.