From fd989686feaf1bb60be051315c169bb5376fd6c6 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Mon, 2 Nov 2026 23:58:49 -0500 Subject: [PATCH] Check out text files with LF on every machine Hash and immutable-file checks compare raw bytes, so a Windows clone with core.autocrlf=true could not rebuild its indexes: install_immutable found source_tokens.json converted to CRLF and refused it. The index already holds LF everywhere, so pinning the checkout needs no renormalization. Co-Authored-By: Claude Opus 5.5 --- .gitattributes | 3 +++ tests/unit/test_line_endings.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .gitattributes create mode 100644 tests/unit/test_line_endings.py diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..887afc6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Hash and immutable-file checks compare raw bytes, so text files must have the same line +# endings on every machine. Git's binary detection leaves images and archives alone. +* text=auto eol=lf diff --git a/tests/unit/test_line_endings.py b/tests/unit/test_line_endings.py new file mode 100644 index 0000000..ed6e964 --- /dev/null +++ b/tests/unit/test_line_endings.py @@ -0,0 +1,31 @@ +"""Hash and immutable-file checks read raw bytes, so a checkout must not convert line endings.""" + +from __future__ import annotations + +import subprocess +from pathlib import Path + +import pytest + +pytestmark = pytest.mark.no_seeded_repo + +REPO = Path(__file__).resolve().parents[2] + + +@pytest.mark.parametrize( + "path", + [ + "content/mt/source_snapshots/mt.f352dcdea73daa036a807af6/source_tokens.json", + "content/audit/packages/source_policy.ab4537d9ff4ed35bb62e4059.json", + "app/services/greek_lexical_forms.py", + ], +) +def test_byte_checked_files_check_out_with_lf(path: str) -> None: + result = subprocess.run( + ["git", "check-attr", "eol", "--", path], + cwd=REPO, + capture_output=True, + text=True, + check=True, + ) + assert result.stdout.strip() == f"{path}: eol: lf"