Skip to content

Commit bb12c13

Browse files
committed
Git fetcher: Don't compute lastModified if it's already specified
Same as revCount.
1 parent 2c2a0d8 commit bb12c13

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/libfetchers/fetchers.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,6 @@ void Input::checkLocks(Input specified, Input & result)
269269
}
270270
}
271271

272-
if (auto prevLastModified = specified.getLastModified()) {
273-
if (result.getLastModified() != prevLastModified)
274-
throw Error(
275-
"'lastModified' attribute mismatch in input '%s', expected %d, got %d",
276-
result.to_string(),
277-
*prevLastModified,
278-
result.getLastModified().value_or(-1));
279-
}
280-
281272
if (auto prevRev = specified.getRev()) {
282273
if (result.getRev() != prevRev)
283274
throw Error("'rev' attribute mismatch in input '%s', expected %s", result.to_string(), prevRev->gitRev());

src/libfetchers/git.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,12 +889,14 @@ struct GitInputScheme : InputScheme
889889

890890
auto rev = *input.getRev();
891891

892-
input.attrs.insert_or_assign("lastModified", getLastModified(settings, repoInfo, repoDir, rev));
892+
/* Skip lastModified computation if it's already supplied by the caller.
893+
We don't care if they specify an incorrect value; it doesn't
894+
matter for security, unlike narHash. */
895+
if (!input.attrs.contains("lastModified"))
896+
input.attrs.insert_or_assign("lastModified", getLastModified(settings, repoInfo, repoDir, rev));
893897

894898
if (!getShallowAttr(input)) {
895-
/* Skip revCount computation if it's already supplied by the caller.
896-
We don't care if they specify an incorrect value; it doesn't
897-
matter for security, unlike narHash. */
899+
/* Like lastModified, skip revCount if supplied by the caller. */
898900
if (!input.attrs.contains("revCount"))
899901
input.attrs.insert_or_assign("revCount", getRevCount(settings, repoInfo, repoDir, rev));
900902
}

0 commit comments

Comments
 (0)