From 69deca194ec789fa63d222bbd6549dab73328022 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 27 Jul 2017 17:02:25 +0200 Subject: builtins.fetchgit: Use proper refs locally --- src/libexpr/primops/fetchgit.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/libexpr/primops/fetchgit.cc') 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, 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"; -- cgit v1.2.3