builtins.fetchgit: Use proper refs locally

This commit is contained in:
Eelco Dolstra 2017-07-27 17:02:25 +02:00
parent 6d7de7f3de
commit 69deca194e
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -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); //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; 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)); std::string commitHash = chomp(readFile(localRefFile));
unlink(localRefFile.c_str());
printTalkative("using revision %s of repo %s", uri, commitHash); printTalkative("using revision %s of repo %s", uri, commitHash);
Path storeLink = cacheDir + "/" + commitHash + ".link"; Path storeLink = cacheDir + "/" + commitHash + ".link";