Simplify .gitattributes handling for C/C++ headers#2129
Merged
Conversation
The old attributes treated every .h and .hpp file as binary, then carved out path-specific exceptions for headers maintained in this repository. That was based on an outdated assumption that checked-in headers were broadly generated or hands-off inputs. The tracked header set is much smaller and clearer: the only header that needs Git-level byte preservation is the vendored DLPack header. Keep that file opted out of Git text normalization with -text and an explicit !eol reset, while forcing text diffs so review output stays readable. All other tracked headers now inherit the repository default text eol=lf behavior, consistent with Python files and other normal source. This includes repo-owned C++ helpers as well as the AOTI shim adaptation, which is third-party-derived but maintained here rather than a byte-for-byte vendored header. For a fresh clone, this should not change the bytes of the nine existing tracked headers on Linux or Windows. The blobs are already stored with LF line endings. On main, exception headers checked out as LF via text eol=lf while the remaining binary-classified headers were written as raw LF blob bytes. After this change, ordinary headers still check out as LF via text eol=lf, and DLPack remains raw LF. For a fresh clone, the only observable change is Git behavior: ordinary headers stop being binary-classified, and DLPack remains no-normalization but becomes text-diffable. Pre-commit behavior is unchanged and still governed by hook-specific matching.
Contributor
Author
|
Running the full CI for this out of an abundance of caution, in case there are any unexpected |
This comment has been minimized.
This comment has been minimized.
cryos
approved these changes
May 22, 2026
Andy-Jost
approved these changes
May 22, 2026
|
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.
Summary
This simplifies the
.gitattributeshandling for checked-in.hand.hppfiles.Plain
git diffnow works intuitively across the tracked source headers, so changes in these files appear as normal text diffs without requiringgit diff -a. This should also make future header additions less surprising. A newly added.hor.hppfile will behave like normal source by default, instead of silently becoming binary-classified unless someone remembers to add a matching exception rule.The old attributes treated every C/C++ header as binary, then carved out path-specific exceptions for headers maintained in this repository. That was based on an outdated assumption that checked-in headers were broadly generated or hands-off inputs.
The tracked header set is much smaller and clearer: the only header that needs Git-level byte preservation is the vendored DLPack header. This change keeps
cuda_core/cuda/core/_include/dlpack.hopted out of Git text normalization with-textand an explicit!eolreset, while forcing text diffs so review output stays readable.All other tracked headers now inherit the repository default
text eol=lfbehavior, consistent with Python files and other normal source. This includes repo-owned C++ helpers as well as the AOTI shim adaptation, which is third-party-derived but maintained here rather than a byte-for-byte vendored header.Fresh Clone Behavior
For a fresh clone, this should not change the bytes of the nine existing tracked headers on Linux or Windows. The blobs are already stored with LF line endings.
On
main, exception headers checked out as LF viatext eol=lf, while the remaining binary-classified headers were written as raw LF blob bytes. After this change, ordinary headers still check out as LF viatext eol=lf, and DLPack remains raw LF.For a fresh clone, the only observable change is Git behavior: ordinary headers stop being binary-classified, and DLPack remains no-normalization but becomes text-diffable.
Pre-commit
Pre-commit behavior is unchanged and still governed by hook-specific matching.
Validation
Checked the effective attributes with
git check-attrand verified the tracked header line-ending state withgit ls-files --eol.Details
This change affects the attributes for the nine tracked
.hand.hppfiles.These five files were already treated as text on
mainby path-specific exception rules that overrode the broadbinaryheader rule with-binary text diff:These three files were binary-classified on
main, but are maintained source in this repository and should inherit the sametext eol=lfbehavior as other normal source files:This one file remains special-cased because it is the byte-for-byte vendored header that should not be normalized by Git: