From 62fb242ad64ed97faaf61a8d2d13c237480d4bb5 Mon Sep 17 00:00:00 2001 From: Tim Neumann Date: Fri, 30 Sep 2016 11:15:37 +0200 Subject: [PATCH] fix out-of-tree rustbuild --- src/bootstrap/lib.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 3d1cf47cb7e90..0ca6e3fefaa26 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -557,17 +557,22 @@ impl Build { continue } - if !submodule.path.exists() { - t!(fs::create_dir_all(&submodule.path)); - } + // `submodule.path` is the relative path to a submodule (from the repository root) + // `submodule_path` is the path to a submodule from the cwd + + // use `submodule.path` when e.g. executing a submodule specific command from the + // repository root + // use `submodule_path` when e.g. executing a normal git command for the submodule + // (set via `current_dir`) + let submodule_path = self.src.join(submodule.path); match submodule.state { State::MaybeDirty => { // drop staged changes - self.run(git().current_dir(submodule.path) + self.run(git().current_dir(&submodule_path) .args(&["reset", "--hard"])); // drops unstaged changes - self.run(git().current_dir(submodule.path) + self.run(git().current_dir(&submodule_path) .args(&["clean", "-fdx"])); }, State::NotInitialized => { @@ -577,9 +582,9 @@ impl Build { State::OutOfSync => { // drops submodule commits that weren't reported to the (outer) git repository self.run(git_submodule().arg("update").arg(submodule.path)); - self.run(git().current_dir(submodule.path) + self.run(git().current_dir(&submodule_path) .args(&["reset", "--hard"])); - self.run(git().current_dir(submodule.path) + self.run(git().current_dir(&submodule_path) .args(&["clean", "-fdx"])); }, }