about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2024-07-14 10:58:57 +0200
committerJakub Beránek <berykubik@gmail.com>2024-07-15 20:07:57 +0200
commit7a5411757124b3cdc4aff5ea86cbe91f5e58a618 (patch)
tree1d8e97524b7d9f66d0b44c696e7fc1f908ff1b34
parentff9c4883449ff895942398be656e260891755e4a (diff)
downloadrust-7a5411757124b3cdc4aff5ea86cbe91f5e58a618.tar.gz
rust-7a5411757124b3cdc4aff5ea86cbe91f5e58a618.zip
Make sure to run git submodule checkout in dry run mode
-rw-r--r--src/bootstrap/src/lib.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index 52e28fbd059..c2367375708 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -490,7 +490,17 @@ impl Build {
             return;
         }
 
-        let submodule_git = || helpers::git(Some(&absolute_path)).capture_stdout();
+        // Submodule updating actually happens during in the dry run mode. We need to make sure that
+        // all the git commands below are actually executed, because some follow-up code
+        // in bootstrap might depend on the submodules being checked out. Furthermore, not all
+        // the command executions below work with an empty output (produced during dry run).
+        // Therefore, all commands below are marked with `run_always()`, so that they also run in
+        // dry run mode.
+        let submodule_git = || {
+            let mut cmd = helpers::git(Some(&absolute_path)).capture_stdout();
+            cmd.run_always();
+            cmd
+        };
 
         // Determine commit checked out in submodule.
         let checked_out_hash = submodule_git().args(["rev-parse", "HEAD"]).run(self).stdout();
@@ -498,6 +508,7 @@ impl Build {
         // Determine commit that the submodule *should* have.
         let recorded = helpers::git(Some(&self.src))
             .capture_stdout()
+            .run_always()
             .args(["ls-tree", "HEAD"])
             .arg(relative_path)
             .run(self)
@@ -514,6 +525,7 @@ impl Build {
 
         println!("Updating submodule {}", relative_path.display());
         helpers::git(Some(&self.src))
+            .run_always()
             .args(["submodule", "-q", "sync"])
             .arg(relative_path)
             .run(self);
@@ -524,12 +536,14 @@ impl Build {
             // even though that has no relation to the upstream for the submodule.
             let current_branch = helpers::git(Some(&self.src))
                 .capture_stdout()
+                .run_always()
                 .args(["symbolic-ref", "--short", "HEAD"])
                 .run(self)
                 .stdout_if_ok()
                 .map(|s| s.trim().to_owned());
 
             let mut git = helpers::git(Some(&self.src)).allow_failure();
+            git.run_always();
             if let Some(branch) = current_branch {
                 // If there is a tag named after the current branch, git will try to disambiguate by prepending `heads/` to the branch name.
                 // This syntax isn't accepted by `branch.{branch}`. Strip it.