Skip to content

Commit

Permalink
Simplify commit check
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Jun 5, 2021
1 parent 28d0d0c commit 2fbe2ca
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,33 +107,26 @@ pub(crate) fn update_llvm_submodule(build: &Build) {
}

// check_submodule
let buf;
let checked_out = if build.config.fast_submodules {
buf = output(
if build.config.fast_submodules {
let checked_out_hash = output(
Command::new("git")
.args(&["rev-parse", "HEAD"])
.current_dir(build.config.src.join(llvm_project)),
);
Some(buf.trim_end())
} else {
None
};
// update_submodules
let recorded = output(
Command::new("git")
.args(&["ls-tree", "HEAD"])
.arg(llvm_project)
.current_dir(&build.config.src),
);
let actual_hash = recorded
.split_whitespace()
.nth(2)
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));

// update_submodules
let recorded = output(
Command::new("git")
.args(&["ls-tree", "HEAD"])
.arg(llvm_project)
.current_dir(&build.config.src),
);
let hash = recorded
.split_whitespace()
.nth(2)
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));

// update_submodule
if let Some(llvm_hash) = checked_out {
if hash == llvm_hash {
// update_submodule
if actual_hash == checked_out_hash.trim_end() {
// already checked out
return;
}
Expand Down

0 comments on commit 2fbe2ca

Please sign in to comment.