forked from lix-project/lix
fetchGit: fix submodule corner case by fetching all refs from cacheDir
Due to fetchGit not checking if rev is an ancestor of ref (there is even a FIXME comment about it in the code), the cache repo might not have the ref even though it has the rev. This doesn't matter when submodule = false, but the submodule = true code blows up because it tries to fetch the (missing) ref from the cache repo. Fix this in the simplest way possible: fetch all refs from the local cache repo when submodules = true. TODO: Add tests.
This commit is contained in:
parent
cc522d0d23
commit
f686efeed4
|
@ -183,8 +183,11 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
|
|||
AutoDelete delTmpGitDir(tmpGitDir, true);
|
||||
|
||||
runProgram("git", true, { "init", tmpDir, "--separate-git-dir", tmpGitDir });
|
||||
// TODO: the cacheDir repo might lack the ref (it only checks if rev
|
||||
// exists, see FIXME above) so use a big hammer and fetch everything to
|
||||
// ensure we get the rev.
|
||||
runProgram("git", true, { "-C", tmpDir, "fetch", "--quiet", "--force",
|
||||
"--", cacheDir, fmt("%s", *ref) });
|
||||
"--update-head-ok", "--", cacheDir, "refs/*:refs/*" });
|
||||
|
||||
runProgram("git", true, { "-C", tmpDir, "checkout", "--quiet", gitInfo.rev });
|
||||
runProgram("git", true, { "-C", tmpDir, "remote", "add", "origin", uri });
|
||||
|
|
Loading…
Reference in a new issue