Skip to content

Commit d68f7eb

Browse files
committed
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.
1 parent c87ba3f commit d68f7eb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/bootstrap/lib.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,18 @@ impl Build {
556556
continue
557557
}
558558

559+
if !submodule.path.exists() {
560+
t!(fs::create_dir_all(&submodule.path));
561+
}
562+
559563
match submodule.state {
560564
State::MaybeDirty => {
561565
// drop staged changes
562-
self.run(git().arg("-C").arg(submodule.path).args(&["reset", "--hard"]));
566+
self.run(git().current_dir(submodule.path)
567+
.args(&["reset", "--hard"]));
563568
// drops unstaged changes
564-
self.run(git().arg("-C").arg(submodule.path).args(&["clean", "-fdx"]));
569+
self.run(git().current_dir(submodule.path)
570+
.args(&["clean", "-fdx"]));
565571
},
566572
State::NotInitialized => {
567573
self.run(git_submodule().arg("init").arg(submodule.path));
@@ -570,8 +576,10 @@ impl Build {
570576
State::OutOfSync => {
571577
// drops submodule commits that weren't reported to the (outer) git repository
572578
self.run(git_submodule().arg("update").arg(submodule.path));
573-
self.run(git().arg("-C").arg(submodule.path).args(&["reset", "--hard"]));
574-
self.run(git().arg("-C").arg(submodule.path).args(&["clean", "-fdx"]));
579+
self.run(git().current_dir(submodule.path)
580+
.args(&["reset", "--hard"]));
581+
self.run(git().current_dir(submodule.path)
582+
.args(&["clean", "-fdx"]));
575583
},
576584
}
577585
}

0 commit comments

Comments
 (0)