From 427f03997d3da9b5669ba35495094368b9791499 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 23 Aug 2024 16:53:21 +0200 Subject: [PATCH] Only update `src/llvm-project` submodule if already existing --- src/bootstrap/src/core/config/config.rs | 14 +++++++++++++- src/bootstrap/src/lib.rs | 9 +-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index ce23b7735f8bd..bff3493e198f0 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2509,6 +2509,18 @@ impl Config { } } + /// Updates the given submodule only if it's initialized already; nothing happens otherwise. + pub(crate) fn update_existing_submodule(&self, submodule: &str) { + // Avoid running git when there isn't a git checkout. + if !self.submodules() { + return; + } + + if GitInfo::new(false, Path::new(submodule)).is_managed_git_subrepository() { + self.update_submodule(submodule); + } + } + /// Given a path to the directory of a submodule, update it. /// /// `relative_path` should be relative to the root of the git repository, not an absolute path. @@ -2738,7 +2750,7 @@ impl Config { return false; } - self.update_submodule("src/llvm-project"); + self.update_existing_submodule("src/llvm-project"); // Check for untracked changes in `src/llvm-project`. let has_changes = self diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 268392c5fb118..8b489f828d5ac 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -542,14 +542,7 @@ impl Build { /// Updates the given submodule only if it's initialized already; nothing happens otherwise. pub fn update_existing_submodule(&self, submodule: &str) { - // Avoid running git when there isn't a git checkout. - if !self.config.submodules() { - return; - } - - if GitInfo::new(false, Path::new(submodule)).is_managed_git_subrepository() { - self.config.update_submodule(submodule); - } + self.config.update_existing_submodule(submodule) } /// Executes the entire build, as configured by the flags and configuration.