aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-07-27 17:02:25 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-07-27 17:02:25 +0200
commit69deca194ec789fa63d222bbd6549dab73328022 (patch)
treefc1a006f100264ef1c04ef255e2e6e2847695162 /src
parent6d7de7f3ded6254ea3a284b2c9b6a51fc8b041bb (diff)
builtins.fetchgit: Use proper refs locally
Diffstat (limited to 'src')
-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";