Optionally allow git filters to be applied when reading blobs #13993
+90
−33
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.
Motivation
Nix 2.20 introduced a regression (a breaking change) in which git repositories do not properly have filters applied (specifically filters that are configured via
.gitattributes
). This manifests as "NAR hash mismatch" errors when users are upgrading from earlier versions and they have a dependency that uses.gitattributes
to manipulate line endings.curl
is the most notable example I am aware of which, for example, specifies in.gitattributes
that*.bat
files should have CRLF line endings.This change differs from #13428 in that the nix 2.20 behavior is retained as the default, with the previous behavior now being opt-in via the optional
applyFilters
attribute to git flake inputs. As such, this PR does not introduce a breaking change.Context
Fixes #11428, alternative to #13428.
The current nix behaviour seems completely broken when it comes to handling git filters.
The output of the above script on my machine is as follows:
This shows that the way Nix is handling git repositories is inconsistent with git, irrespective of the user and/or system git configuration.
Another manifestation of this bug is that the NAR hash for a git repository can change depending on the order of evaluations. This can be demonstrated by the following script:
The output of this script is as follows:
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.