fetchGit: allow fetching explicit refs

Trying to fetch refs that are not in refs/heads currently fails because
it looks for refs/heads/refs/foo instead of refs/foo.

eg.

	builtins.fetchGit {
	  url = https://github.com/NixOS/nixpkgs.git;
	  ref = "refs/pull/1024/head;
	}
This commit is contained in:
Daiderd Jordan 2018-12-14 20:07:23 +01:00
parent c37e6d77ea
commit 7e35e914c1
No known key found for this signature in database
GPG key ID: D02435D05B810C96

View file

@ -94,7 +94,11 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
runProgram("git", true, { "init", "--bare", cacheDir }); runProgram("git", true, { "init", "--bare", cacheDir });
} }
Path localRefFile = cacheDir + "/refs/heads/" + *ref; Path localRefFile;
if (ref->compare(0, 5, "refs/") == 0)
localRefFile = cacheDir + "/" + *ref;
else
localRefFile = cacheDir + "/refs/heads/" + *ref;
bool doFetch; bool doFetch;
time_t now = time(0); time_t now = time(0);