From d68f7eb865b1b1be5393b440d9122d4f7c4497c2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 13 Sep 2016 12:30:17 -0700 Subject: [PATCH] rustbuild: Use current_dir instead of -C Apparently some versions of git don't support the `-C` flag, so let's use the guaranteed-to-work `current_dir` function. --- src/bootstrap/lib.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 94c14f7ea2546..13eb0299e35f4 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -556,12 +556,18 @@ impl Build { continue } + if !submodule.path.exists() { + t!(fs::create_dir_all(&submodule.path)); + } + match submodule.state { State::MaybeDirty => { // drop staged changes - self.run(git().arg("-C").arg(submodule.path).args(&["reset", "--hard"])); + self.run(git().current_dir(submodule.path) + .args(&["reset", "--hard"])); // drops unstaged changes - self.run(git().arg("-C").arg(submodule.path).args(&["clean", "-fdx"])); + self.run(git().current_dir(submodule.path) + .args(&["clean", "-fdx"])); }, State::NotInitialized => { self.run(git_submodule().arg("init").arg(submodule.path)); @@ -570,8 +576,10 @@ 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().arg("-C").arg(submodule.path).args(&["reset", "--hard"])); - self.run(git().arg("-C").arg(submodule.path).args(&["clean", "-fdx"])); + self.run(git().current_dir(submodule.path) + .args(&["reset", "--hard"])); + self.run(git().current_dir(submodule.path) + .args(&["clean", "-fdx"])); }, } }