@@ -790,27 +790,27 @@ struct GitInputScheme : InputScheme
790790 bool smudgeLfs = getLfsAttr (input);
791791 auto accessor = repo->getAccessor (rev, exportIgnore, " «" + input.to_string (true ) + " »" , smudgeLfs);
792792
793- /* Backward compatibility hack for locks produced by Nix < 2.20 that depend on Git filters. Nix >= 2.20 doesn't
794- * apply Git filters, so we may get a NAR hash mismatch. If that happens, try again with filters enabled. */
793+ /* Backward compatibility hack for locks produced by Nix < 2.20 that depend on Nix applying Git filters or
794+ * `export-ignore`. Nix >= 2.20 doesn't do those, so we may get a NAR hash mismatch. If that happens, try again
795+ * with filters and export-ignore enabled. */
795796 if (auto expectedNarHash = input.getNarHash ()) {
796797 if (accessor->pathExists (CanonPath (" .gitattributes" ))) {
797798 accessor->fingerprint = makeFingerprint (input, rev);
798- auto narHashNoFilters =
799+ auto narHashNew =
799800 fetchToStore2 (settings, *store, {accessor}, FetchMode::DryRun, input.getName ()).second ;
800- if (expectedNarHash != narHashNoFilters) {
801- auto accessor2 =
802- repo->getAccessor (rev, exportIgnore, " «" + input.to_string (true ) + " »" , smudgeLfs, true );
803- accessor2->fingerprint = makeFingerprint (input, rev) + " ;f" ;
804- auto narHashFilters =
801+ if (expectedNarHash != narHashNew) {
802+ auto accessor2 = repo->getAccessor (rev, true , " «" + input.to_string (true ) + " »" , smudgeLfs, true );
803+ accessor2->fingerprint = makeFingerprint (input, rev) + " ;e;f" ;
804+ auto narHashOld =
805805 fetchToStore2 (settings, *store, {accessor2}, FetchMode::DryRun, input.getName ()).second ;
806- if (expectedNarHash == narHashFilters ) {
806+ if (expectedNarHash == narHashOld ) {
807807 warn (
808- " Git input '%s' specifies a NAR hash '%s' that is only correct if Git filters are applied .\n "
809- " This is pre- Nix 2.20 behavior; in Nix 2.20 and later, Git filters are not applied .\n "
808+ " Git input '%s' specifies a NAR hash '%s' that was created by Nix < 2.20 .\n "
809+ " Nix >= 2.20 does not apply Git filters and `export-ignore` by default, which changes the NAR hash .\n "
810810 " Please update the NAR hash to '%s'." ,
811811 input.to_string (),
812812 expectedNarHash->to_string (HashFormat::SRI, true ),
813- narHashNoFilters .to_string (HashFormat::SRI, true ));
813+ narHashNew .to_string (HashFormat::SRI, true ));
814814 accessor = accessor2;
815815 }
816816 }
0 commit comments