Support .gitattributes in subdirectories#335
Conversation
📝 WalkthroughWalkthroughFixes an error-message hash ordering, simplifies Git input fingerprinting by removing a Changes
Sequence Diagram(s)sequenceDiagram
participant Tester
participant Fetcher
participant GitAccessor
participant LegacyAccessor
participant Store
Tester->>Fetcher: request Git input
Fetcher->>GitAccessor: construct accessor (nix219Compat? smudgeLfs?)
GitAccessor->>Store: compute store path hash / narHashNew (if expected provided)
Store-->>GitAccessor: narHashComputed
GitAccessor->>GitAccessor: compare expectedNarHash vs narHashComputed
alt match
GitAccessor-->>Fetcher: return new accessor
else mismatch
GitAccessor->>LegacyAccessor: compute legacy nar hash
alt legacy matches
LegacyAccessor-->>Fetcher: return legacy accessor (fallback)
else
GitAccessor-->>Fetcher: return accessor with updated path/hash
end
end
Fetcher-->>Tester: accessor returned
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
For performance, the Git backwards compatibility hack was only applied to repositories that had a .gitattributes in the root directory. However, there are real-world repos that have it in subdirectories, so drop that condition.
2e99ba0 to
a1cf632
Compare
This was breaking a flake-regressions test and is a bug in general.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/libfetchers/git.cc (1)
1000-1014:⚠️ Potential issue | 🟡 MinorWarn only when legacy semantics are actually used.
IfexpectedNarHashmatches the modern hash, the code switches to the modern accessor but still logs “Using Nix 2.19 semantics…”, which is misleading.Suggested minimal adjustment
- warn("Using Nix 2.19 semantics to export Git repository '%s'.", input.to_string()); + bool useLegacy = true; auto accessorModern = accessor; accessor = getLegacyGitAccessor(store, repoInfo, repoDir, rev, options); if (expectedNarHash) { auto narHashLegacy = fetchToStore2(settings, store, {accessor}, FetchMode::DryRun, input.getName()).second; if (expectedNarHash != narHashLegacy) { auto narHashModern = fetchToStore2(settings, store, {accessorModern}, FetchMode::DryRun, input.getName()).second; if (expectedNarHash == narHashModern) - accessor = accessorModern; + { accessor = accessorModern; useLegacy = false; } } } + if (useLegacy) + warn("Using Nix 2.19 semantics to export Git repository '%s'.", input.to_string());
Motivation
For performance, the Git backwards compatibility hack was only applied to repositories that had a
.gitattributesin the root directory. However, there are real-world repos that have it in subdirectories, so drop that condition.Context
Summary by CodeRabbit
Bug Fixes
Improvements
Tests