chore: add .gitattributes to pin line endings - #180
Merged
Merged
Conversation
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
force-pushed
the
chore/gitattributes
branch
from
August 31, 2026 11:40
f4ddb94 to
2ef7021
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.cppwas 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 blameis poisoned.The fix
* text=autohas 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 withtext eol=crlfso 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):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,kanall pass;examples/xorbuilds;examples/energy_efficiencybuilds 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