aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops/fetchgit.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/primops/fetchgit.cc')
-rw-r--r--src/libexpr/primops/fetchgit.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libexpr/primops/fetchgit.cc b/src/libexpr/primops/fetchgit.cc
index 1ac9b364f..b64a00b61 100644
--- a/src/libexpr/primops/fetchgit.cc
+++ b/src/libexpr/primops/fetchgit.cc
@@ -20,15 +20,14 @@ Path exportGit(ref<Store> store, const std::string & uri, const std::string & re
//Activity act(*logger, lvlInfo, format("fetching Git repository ā€˜%sā€™") % uri);
- std::string localRef = "pid-" + std::to_string(getpid());
+ std::string localRef = hashString(htSHA256, fmt("%s-%s", uri, rev)).to_string(Base32, false);
+
Path localRefFile = cacheDir + "/refs/heads/" + localRef;
- runProgram("git", true, { "-C", cacheDir, "fetch", uri, rev + ":" + localRef });
+ runProgram("git", true, { "-C", cacheDir, "fetch", "--force", uri, rev + ":" + localRef });
std::string commitHash = chomp(readFile(localRefFile));
- unlink(localRefFile.c_str());
-
printTalkative("using revision %s of repo ā€˜%sā€™", uri, commitHash);
Path storeLink = cacheDir + "/" + commitHash + ".link";