build: normalize line endings to LF across all platforms

Add explicit file-type rules to .gitattributes so text files are stored
and checked out with LF line endings regardless of platform. This
prevents issues where Windows git (or CI actions/checkout) converts
LF to CRLF, breaking comptime parsers that split embedded files by
'\n' and end up with trailing '\r' in parsed tokens.

Key changes:
- Source code (*.zig, *.c, *.h, etc.): always LF
- Config/build files (*.zon, *.nix, *.md, etc.): always LF
- Text data files (*.txt): always LF (for embedded file parsing)
- Windows resource files (*.rc, *.manifest): preserve as-is
  (native Windows tooling expects CRLF)
- Binary files: explicitly marked as binary

Removed the legacy rgb.txt -text rule since *.txt now handles it
uniformly with code-level CRLF handling as defense-in-depth.
This commit is contained in:
Alessandro De Blasis
2026-03-26 02:17:36 +01:00
committed by Mitchell Hashimoto
parent 650b9d470a
commit dc3db7b99f

45
.gitattributes vendored
View File

@@ -1,3 +1,47 @@
#--------------------------------------------------------------------
# Line endings
#--------------------------------------------------------------------
# Source code - always LF
*.zig text eol=lf
*.c text eol=lf
*.h text eol=lf
*.cpp text eol=lf
*.m text eol=lf
*.swift text eol=lf
*.py text eol=lf
*.sh text eol=lf
# Config/build files - always LF
*.zon text eol=lf
*.nix text eol=lf
*.md text eol=lf
*.json text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.toml text eol=lf
CMakeLists.txt text eol=lf
*.cmake text eol=lf
Makefile text eol=lf
# Text data files - always LF (embedded in Zig, parsed with \n split)
*.txt text eol=lf
# Windows resource files - preserve as-is (native Windows tooling)
*.rc -text
*.manifest -text
# Binary files
*.png binary
*.ico binary
*.icns binary
*.ttf binary
*.otf binary
*.glsl binary
*.blp binary
#--------------------------------------------------------------------
# Linguist
#--------------------------------------------------------------------
build.zig.zon.nix linguist-generated=true
build.zig.zon.txt linguist-generated=true
build.zig.zon.json linguist-generated=true
@@ -12,4 +56,3 @@ src/font/nerd_font_attributes.zig linguist-generated=true
src/font/nerd_font_codepoint_tables.py linguist-generated=true
src/font/res/** linguist-vendored
src/terminal/res/** linguist-vendored
src/terminal/res/rgb.txt -text