about summary refs log tree commit diff
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 1ac9b364f520..b64a00b6146f 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";