Skip to content

Commit

Permalink
Only update src/llvm-project submodule if already existing
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Aug 23, 2024
1 parent a60a9e5 commit 427f039
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
14 changes: 13 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 427f039

Please sign in to comment.