Skip to content

Commit 2fbe2ca

Browse files
committed
Simplify commit check
1 parent 28d0d0c commit 2fbe2ca

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/bootstrap/native.rs

+15-22
Original file line numberDiff line numberDiff line change
@@ -107,33 +107,26 @@ pub(crate) fn update_llvm_submodule(build: &Build) {
107107
}
108108

109109
// check_submodule
110-
let buf;
111-
let checked_out = if build.config.fast_submodules {
112-
buf = output(
110+
if build.config.fast_submodules {
111+
let checked_out_hash = output(
113112
Command::new("git")
114113
.args(&["rev-parse", "HEAD"])
115114
.current_dir(build.config.src.join(llvm_project)),
116115
);
117-
Some(buf.trim_end())
118-
} else {
119-
None
120-
};
116+
// update_submodules
117+
let recorded = output(
118+
Command::new("git")
119+
.args(&["ls-tree", "HEAD"])
120+
.arg(llvm_project)
121+
.current_dir(&build.config.src),
122+
);
123+
let actual_hash = recorded
124+
.split_whitespace()
125+
.nth(2)
126+
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
121127

122-
// update_submodules
123-
let recorded = output(
124-
Command::new("git")
125-
.args(&["ls-tree", "HEAD"])
126-
.arg(llvm_project)
127-
.current_dir(&build.config.src),
128-
);
129-
let hash = recorded
130-
.split_whitespace()
131-
.nth(2)
132-
.unwrap_or_else(|| panic!("unexpected output `{}`", recorded));
133-
134-
// update_submodule
135-
if let Some(llvm_hash) = checked_out {
136-
if hash == llvm_hash {
128+
// update_submodule
129+
if actual_hash == checked_out_hash.trim_end() {
137130
// already checked out
138131
return;
139132
}

0 commit comments

Comments
 (0)