normalize line endings with .gitattributes - #60
Merged
Conversation
Contributors work across Windows, Linux and macOS and the repository had no .gitattributes, so files were committed with whatever endings the author's editor produced. Three text files had ended up with CRLF while everything else was LF: NAMESPACE, tests/test-all.R and tests/testthat/test-NetLogoR-classes.R. `* text=auto` stores LF in the repository and checks out whatever is native, so this stops mattering. Binary types are spelled out so they are never touched, and the common text types so they are never misdetected. The three files are renormalized here. Apart from .gitattributes itself the change is only the removal of carriage returns: git diff --cached --ignore-cr-at-eol --stat # .gitattributes | 35 +++++++++ R CMD build already leaves .gitattributes out of the tarball, so it needs no .Rbuildignore entry. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
That commit rewrote three files end to end without changing anything in them, so it only gets in the way when tracking down when a line actually changed. GitHub reads this file automatically; locally it needs git config blame.ignoreRevsFile .git-blame-ignore-revs Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The repository had no
.gitattributes, and contributors work across Windows, Linux and macOS, so files were committed with whatever line endings the author's editor produced. Three text files had drifted to CRLF while everything else was LF:NAMESPACEtests/test-all.Rtests/testthat/test-NetLogoR-classes.R* text=autostores LF in the repository and checks out whatever is native, so this stops mattering. Binary types are spelled out so they are never touched, common text types so they are never misdetected.Reviewing this
The renormalization looks enormous because two files were rewritten end to end, but the only content change is
.gitattributesitself:Reviewing with whitespace ignored, or just reading that one file, is enough.
The renormalization commit is listed in a new
.git-blame-ignore-revs, so it does not get in the way ofgit blame. GitHub honours that file automatically; locally it needsgit config blame.ignoreRevsFile .git-blame-ignore-revs.Why now
Mixed endings caused a real failure while rebasing #59. Editing the CRLF test file with a script silently rewrote it as LF, turning an 81-line addition into a 250/169 whole-file diff, and dropped a closing
})— because Python'ssplitlines()splits on more characters than\n, so line indices computed that way disagree withgrep -n. The test suite caught it, but it should not have been possible in the first place.This was deliberately held until #57, #58 and #59 had all landed, since renormalizing conflicts with anything in flight.
Verification
Checked against a fresh clone of the branch rather than the existing working tree, which is the only way to see what a new checkout actually gets:
R CMD check --as-cran: 0 errors, 0 warnings, 0 notesR CMD buildalready leaves.gitattributesout of the tarball, but it does not exclude.git-blame-ignore-revs— that produced achecking for hidden files and directoriesNOTE, so it is added to.Rbuildignore.🤖 Generated with Claude Code