Repository navigation
Add a .gitattributes enforcing LF line endings - #677
Open
raffaelemancuso wants to merge 1 commit into
Open
raffaelemancuso wants to merge 1 commit into
raffaelemancuso wants to merge 1 commit into
Conversation
Text files are now stored and checked out with LF, on every platform. The motivation is generated files: on Windows, Rcpp::compileAttributes() and roxygen2 write CRLF, so regenerating R/RcppExports.R and src/RcppExports.cpp turned into a whole-file diff (~1,580 lines) that buried the actual signature changes. With eol=lf the regeneration is a no-op unless the generated code really changed. Binary artifacts are listed explicitly so the line-ending filter never touches them and git does not try to diff them as text: images, fonts, pdf/Office documents, the .RData and .dta data sets, on-disk databases and archives. The entries cover the types currently in the repository (png/PNG, dta, ttf, woff2, RData, pdf) plus the ones likely to appear. Only README.md needed renormalising; the 184 binary files in the repository were verified byte-identical afterwards.
This branch has not been deployed
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.
Why
On Windows,
Rcpp::compileAttributes()androxygen2write CRLF, while theblobs in the repository are LF. Regenerating therefore rewrites
R/RcppExports.Randsrc/RcppExports.cppin full — about 1,580 lines ofline-ending churn that buries whatever actually changed. I hit this while
preparing another PR: the real change was 56 lines, the diff showed 1,636.
With
eol=lf, regenerating is a no-op unless the generated code really changed.Verified: after this change, running
compileAttributes()(which still writes323 CRLF pairs into
R/RcppExports.R) leavesgit diff --quietreturning 0.What is in it
plus explicit
binaryentries, so the line-ending filter never touches binaryartifacts and git does not try to diff them as text.
I picked the binary list by scanning every tracked file for NUL bytes rather
than guessing from extensions: 184 files across
.png,.PNG,.dta,.ttf,.woff2,.RDataand.pdf. The scan confirmed nothing binary falls outsidethe rules. The uppercase
*.PNGentry matters — there are three such filesunder
vignettes/images/, and these patterns are matched case-sensitively.I also added entries for types likely to appear later (Office documents,
.rds/.rda, parquet, duckdb, archives).Renormalisation
Only
README.mdneeded it — it was the single text file in the repositorycarrying CRLF. Its diff is line-endings only.
The 184 binary files were verified byte-identical afterwards by comparing
SHA-256 against
HEAD, andgit check-attrconfirms they resolve withtextunset, so the
eolrule is inert for them.R CMD INSTALLsucceeds and thehelp indices build.
One expected cosmetic effect: a file freshly written with CRLF shows as
Mingit statuswith the notice "CRLF will be replaced by LF the next time Gittouches it", while
git diffis empty and there is nothing to commit.If you would rather keep the renormalisation out of
git blame, the commit cango in a
.git-blame-ignore-revs.Note
Independent of my two other PRs; they touch disjoint files.