1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-17 07:52:43 +01:00

Git fetcher: Make dirty repos with no commits cacheable

This commit is contained in:
Eelco Dolstra 2025-06-16 18:16:30 +02:00
parent 7469e7aa57
commit 5329a45ade

View file

@ -860,7 +860,7 @@ struct GitInputScheme : InputScheme
return makeFingerprint(*rev); return makeFingerprint(*rev);
else { else {
auto repoInfo = getRepoInfo(input); auto repoInfo = getRepoInfo(input);
if (auto repoPath = repoInfo.getPath(); repoPath && repoInfo.workdirInfo.headRev && repoInfo.workdirInfo.submodules.empty()) { if (auto repoPath = repoInfo.getPath(); repoPath && repoInfo.workdirInfo.submodules.empty()) {
/* Calculate a fingerprint that takes into account the /* Calculate a fingerprint that takes into account the
deleted and modified/added files. */ deleted and modified/added files. */
HashSink hashSink{HashAlgorithm::SHA512}; HashSink hashSink{HashAlgorithm::SHA512};
@ -873,7 +873,7 @@ struct GitInputScheme : InputScheme
writeString("deleted:", hashSink); writeString("deleted:", hashSink);
writeString(file.abs(), hashSink); writeString(file.abs(), hashSink);
} }
return makeFingerprint(*repoInfo.workdirInfo.headRev) return makeFingerprint(repoInfo.workdirInfo.headRev.value_or(nullRev))
+ ";d=" + hashSink.finish().first.to_string(HashFormat::Base16, false); + ";d=" + hashSink.finish().first.to_string(HashFormat::Base16, false);
} }
return std::nullopt; return std::nullopt;