Fix the origin URL used for fetching submodules
We cannot use 'actualUrl', because for file:// repos that's not the original URL that the repo was fetched from. This is a problem since submodules may be relative to the original URL. Fixes e.g. nix eval --impure --json --expr 'builtins.fetchTree { type = "git"; url = "/path/to/blender"; submodules = true; }' where /path/to/blender is a clone of https://github.com/blender/blender.git (which has several relative submodules like '../blender-addons.git').
This commit is contained in:
parent
81e75e4bf6
commit
2edd5cf618
|
@ -627,7 +627,17 @@ struct GitInputScheme : InputScheme
|
||||||
|
|
||||||
runProgram("git", true, { "-C", tmpDir, "checkout", "--quiet", input.getRev()->gitRev() });
|
runProgram("git", true, { "-C", tmpDir, "checkout", "--quiet", input.getRev()->gitRev() });
|
||||||
|
|
||||||
runProgram("git", true, { "-C", tmpDir, "remote", "add", "origin", actualUrl });
|
/* Ensure that we use the correct origin for fetching
|
||||||
|
submodules. This matters for submodules with relative
|
||||||
|
URLs. */
|
||||||
|
if (isLocal) {
|
||||||
|
writeFile(tmpGitDir + "/config", readFile(repoDir + "/" + gitDir + "/config"));
|
||||||
|
|
||||||
|
/* Restore the config.bare setting we may have just
|
||||||
|
nuked. */
|
||||||
|
runProgram("git", true, { "-C", tmpDir, "config", "core.bare", "false" });
|
||||||
|
} else
|
||||||
|
runProgram("git", true, { "-C", tmpDir, "config", "remote.origin.url", actualUrl });
|
||||||
|
|
||||||
{
|
{
|
||||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching submodules of '%s'", tmpDir));
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("fetching submodules of '%s'", tmpDir));
|
||||||
|
|
Loading…
Reference in a new issue