chore: pin LF line endings in .gitattributes

The branding toolkit reads tools/branding-sites.tsv line by line with `read`.
On Windows, Git for Windows' default core.autocrlf=true checks that file out as
CRLF, so every row's last field - the pattern - gains a trailing \r and matches
nothing. In a child repo this made check-branding.sh report all 29 of its sites
as missing on Windows while the same commit passed on the Linux CI runner, and
brand-plugin.sh uses that same field as its sed search pattern. Only *.sh was
pinned to LF, which protected the scripts but not their data.

This is the template, so the fix belongs here: every repo created from it
inherits the policy instead of rediscovering the bug.

    * text=auto eol=lf       LF in the repo and every working tree, every OS
    *.sh text eol=lf         kept explicit: a CRLF shebang is a hard failure
    *.bat/*.cmd eol=crlf     the one exception; cmd.exe misparses LF batch files

An attribute beats core.autocrlf, so a fresh clone gets LF however its machine
is configured. Verified in a throwaway repo under autocrlf=true.

No blob changes: every committed blob was already LF, and
`git add --renormalize .` stages nothing but this file. Working tree
re-checked-out to match (14 files CRLF -> LF). Checker 38 passed / 0 failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LU1NRL7fAaZTtFMTTPn2b1
This commit is contained in:
Mikkeli Matlock
2026-09-14 01:39:17 +09:00
parent 8630ba0c5b
commit 3abbb06073
+19 -3
View File
@@ -1,4 +1,20 @@
# Shell scripts must keep LF endings. core.autocrlf=true on Windows would # Line endings: LF in the repository and in every working tree, on every OS.
# otherwise check them out CRLF, which a strict POSIX sh (dash, CI containers) #
# rejects at the shebang. # This file is the policy, not each machine's git config. Git for Windows installs
# with core.autocrlf=true, which checks text out as CRLF; an attribute here beats
# that setting, so a fresh clone gets LF regardless of how its machine is set up.
#
# It matters beyond tidiness. tools/branding-sites.tsv is read line by line with
# `read`, and under CRLF every row's last field gained a trailing
- so the
# branding checker reported all 29 sites as missing on Windows while passing on the
# Linux CI runner. text=auto leaves genuinely binary files alone.
* text=auto eol=lf
# Shell scripts are pinned explicitly as well: a strict POSIX sh (dash, CI
# containers) rejects a CRLF shebang outright rather than misbehaving quietly. # containers) rejects a CRLF shebang outright rather than misbehaving quietly.
*.sh text eol=lf
# The exception. cmd.exe misparses LF-only batch files around labels and long
# lines, so these alone are checked out CRLF. The repository copy is still LF.
*.bat text eol=crlf