Skip to content

Commit 3fb1a84

Browse files
committed
Add a common Build::src_is_git flag
1 parent 5309a3e commit 3fb1a84

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/bootstrap/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub struct Build {
162162
cxx: HashMap<String, gcc::Tool>,
163163
crates: HashMap<String, Crate>,
164164
is_sudo: bool,
165+
src_is_git: bool,
165166
}
166167

167168
#[derive(Debug)]
@@ -233,6 +234,7 @@ impl Build {
233234
};
234235
let rust_info = channel::GitInfo::new(&src);
235236
let cargo_info = channel::GitInfo::new(&src.join("cargo"));
237+
let src_is_git = src.join(".git").is_dir();
236238

237239
Build {
238240
flags: flags,
@@ -251,6 +253,7 @@ impl Build {
251253
lldb_version: None,
252254
lldb_python_dir: None,
253255
is_sudo: is_sudo,
256+
src_is_git: src_is_git,
254257
}
255258
}
256259

@@ -307,10 +310,7 @@ impl Build {
307310
OutOfSync,
308311
}
309312

310-
if !self.config.submodules {
311-
return
312-
}
313-
if fs::metadata(self.src.join(".git")).is_err() {
313+
if !self.src_is_git || !self.config.submodules {
314314
return
315315
}
316316
let git = || {

src/bootstrap/sanity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn check(build: &mut Build) {
6565

6666
// If we've got a git directory we're gona need git to update
6767
// submodules and learn about various other aspects.
68-
if fs::metadata(build.src.join(".git")).is_ok() {
68+
if build.src_is_git {
6969
need_cmd("git".as_ref());
7070
}
7171

0 commit comments

Comments
 (0)