Skip to content

chore: add .gitattributes to pin line endings - #180

Merged
danmcleran merged 1 commit into
masterfrom
chore/gitattributes
Aug 31, 2026
Merged

danmcleran merged 1 commit into
masterfrom
chore/gitattributes

Conversation

@danmcleran

Copy link
Copy Markdown
Owner

Makes the #178 line-ending mistake structurally impossible instead of dependent on whoever edits next.

The problem

Editing a CRLF file with a tool that normalizes newlines rewrites the whole file. In #178 a +33/-8 change to nn_unit_test.cpp was recorded as 17,011 lines; #179 undid it by hand.

Nothing in CI catches this. Line endings do not affect compilation, so every gate stays green while the diff is unreviewable and git blame is poisoned.

The fix

* text=auto has git store LF in the repository. The 28 files that are CRLF in the working tree — the original core headers, the first examples, the two oldest test suites, plus the UML sources and one dataset — are pinned with text eol=crlf so checkout still gives them CRLF. Everything added since is LF and needs no entry.

Net effect: a tool that converts endings now produces no diff at all, because the index holds LF either way and checkout restores the working-tree convention.

Verified, not assumed

Teeth check — repeated the exact #178 mistake (Python text-mode read/write over nn_unit_test.cpp):

file: ASCII text                     <- converted to LF, as before
git diff --numstat: (empty)          <- no diff
git checkout: CRLF line terminators  <- convention restored

Before this change the same operation produced +8518 -8518.

No working-tree churn — compared every staged file's endings before and after: no file's working-tree line endings change.

Content untouched — every staged change compared with CR stripped: all line-endings only.

Still builds — nn, qlearn, kan all pass; examples/xor builds; examples/energy_efficiency builds and runs, confirming the CRLF dataset still parses.

One-time cost

This renormalizes what the repository stores for those 36 files, so the commit shows a whole-file diff for each. That is the last one they will have for this reason.

🤖 Generated with Claude Code

https://claude.ai/code/session_019tVgXeXCcfbHqfMjhufWzd

Editing a CRLF file with a tool that normalizes newlines rewrites the whole
file. In #178 a +33/-8 change to nn_unit_test.cpp was recorded as 17,011 lines,
which buried the real change and poisoned git blame; #179 undid it by hand.
Nothing in CI catches this -- line endings do not affect compilation, so every
gate stays green while the diff is unreviewable.

This makes the mistake structurally impossible rather than a matter of who
edits next. `* text=auto` has git store LF in the repository, and the files
that are CRLF in the working tree -- the original core headers, the first
examples, the two oldest test suites, the UML sources and one dataset -- are
pinned with `text eol=crlf` so checkout still gives them CRLF. Everything added
since is LF and needs no entry.

The effect is that a tool which converts endings now produces no diff at all:
the index holds LF either way, and checkout restores the working-tree
convention. Verified by repeating the #178 mistake against these rules -- the
same operation that produced +8518/-8518 now produces nothing, and checkout
restores CRLF.

This commit therefore renormalizes what the repository stores for those files.
That is a one-time whole-file diff for each, and the last one they will have
for this reason. Checked two ways first: every staged change is line-endings
only (content compared with CR stripped), and no file's working-tree endings
change.
@danmcleran
danmcleran force-pushed the chore/gitattributes branch from f4ddb94 to 2ef7021 Compare August 31, 2026 11:40
@danmcleran
danmcleran merged commit c2b9f26 into master Aug 31, 2026
24 checks passed
@danmcleran
danmcleran deleted the chore/gitattributes branch August 31, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant