git: every text file checks out with LF, so a Windows checkout with autocrlf on doesn't turn four guard tests red (#1827, EdwinDigital)

TestEveryNoticeIsTranslated (agent), TestBuiltinsTranslated,
TestPurposeAssetMatchesUsage and TestRedactKindsAreRedacts (gui) parse
source files with LF-only patterns. Git for Windows' default
core.autocrlf=true checked those files out with CRLF, and all four
failed there; EdwinDigital found they pass from an LF checkout. A root
.gitattributes with `* text=auto eol=lf` makes every text file check
out with LF whatever autocrlf says. internal/agent/testdata's own
`* -text` still keeps its CRLF .cmd fixtures byte for byte.

The index already holds every text file with LF (git ls-files --eol:
the only i/crlf files are those two -text fixtures), so nothing is
renormalised.

Run: two --shared clones with core.autocrlf=true and a sparse checkout
of internal/gui/assets, notice.go and the mise-windows fixtures. At the
parent, i18n.js and app.js check out with CRLF; at this commit with LF,
snow.cmd keeps CRLF, and git status is clean in both. Not run: the four
guard tests on a Windows checkout (no Go on the Windows box); a
checkout made before this commit keeps its CRLF until the files are
checked out again, as in a fresh clone.
This commit is contained in:
yetone
2026-10-15 02:36:26 +08:00
parent 595b9a25bc
commit bcd7881364
+6
View File
@@ -0,0 +1,6 @@
# Every text file checks out with LF, whatever core.autocrlf says: the
# guard tests parse source files line by line (the notices, the built-in
# and purpose assets, the redaction kinds), and gofmt writes LF. A Windows
# checkout with autocrlf on gave them CRLF and four went red (#1827).
# internal/agent/testdata/.gitattributes keeps its real CRLF bytes.
* text=auto eol=lf