Git fetcher: Don't update mtime of ref file if fetching by rev

This fixes the warning

  $ nix eval --store /tmp/nix --expr 'builtins.fetchTree { type = "git"; url = "https://github.com/DeterminateSystems/attic"; ref = "fixups-for-magic-nix-cache"; rev = "635753a2069d4b8228e846dc5c09ad361c75cd1a"; }'
  warning: could not update mtime for file '/home/eelco/.cache/nix/gitv3/09788h9zgba5lbfkaa6ija2dvi004jwsqjf5ln21i2njs07cz766/refs/heads/fixups-for-magic-nix-cache': error: changing modification time of '"/home/eelco/.cache/nix/gitv3/09788h9zgba5lbfkaa6ija2dvi004jwsqjf5ln21i2njs07cz766/refs/heads/fixups-for-magic-nix-cache"': No such file or directory

When we're fetching by rev, that file doesn't necessarily exist, and we
don't care about it anyway.
This commit is contained in:
Eelco Dolstra 2024-09-09 19:52:21 +02:00
parent 4c7a6ffee7
commit b80b091bac

View file

@ -584,9 +584,10 @@ struct GitInputScheme : InputScheme
} }
try { try {
setWriteTime(localRefFile, now, now); if (!input.getRev())
setWriteTime(localRefFile, now, now);
} catch (Error & e) { } catch (Error & e) {
warn("could not update mtime for file '%s': %s", localRefFile, e.msg()); warn("could not update mtime for file '%s': %s", localRefFile, e.info().msg);
} }
if (!originalRef && !storeCachedHead(repoInfo.url, ref)) if (!originalRef && !storeCachedHead(repoInfo.url, ref))
warn("could not update cached head '%s' for '%s'", ref, repoInfo.url); warn("could not update cached head '%s' for '%s'", ref, repoInfo.url);