Skip to content

Commit

Permalink
fetchGit: Drop unnecessary localRef
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Nov 20, 2018
1 parent 3f4de91 commit 4aee93d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libexpr/primops/fetchGit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
if (rev != "" && !std::regex_match(rev, revRegex))
throw Error("invalid Git revision '%s'", rev);

deletePath(getCacheDir() + "/nix/git");

Path cacheDir = getCacheDir() + "/nix/gitv2/" + hashString(htSHA256, uri).to_string(Base32, false);

if (!pathExists(cacheDir)) {
createDirs(dirOf(cacheDir));
runProgram("git", true, { "init", "--bare", cacheDir });
}

std::string localRef = hashString(htSHA256, fmt("%s-%s", uri, *ref)).to_string(Base32, false);

Path localRefFile = cacheDir + "/refs/heads/" + localRef;
Path localRefFile = cacheDir + "/refs/heads/" + *ref;

bool doFetch;
time_t now = time(0);
Expand Down Expand Up @@ -124,7 +124,7 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,

// FIXME: git stderr messes up our progress indicator, so
// we're using --quiet for now. Should process its stderr.
runProgram("git", true, { "-C", cacheDir, "fetch", "--quiet", "--force", "--", uri, *ref + ":" + localRef });
runProgram("git", true, { "-C", cacheDir, "fetch", "--quiet", "--force", "--", uri, fmt("%s:%s", *ref, *ref) });

struct timeval times[2];
times[0].tv_sec = now;
Expand Down

0 comments on commit 4aee93d

Please sign in to comment.