From 7d3f79458891d2cb9ce2b3d51f8d8f788d36c9e8 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 29 May 2019 18:06:11 -0400 Subject: ignore: remove .git check in some cases When we know we aren't going to process gitignores, we shouldn't waste the syscall in every directory to check for a git repo. --- ignore/src/dir.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ignore/src/dir.rs b/ignore/src/dir.rs index be2b8351..479e0c24 100644 --- a/ignore/src/dir.rs +++ b/ignore/src/dir.rs @@ -197,7 +197,12 @@ impl Ignore { errs.maybe_push(err); igtmp.is_absolute_parent = true; igtmp.absolute_base = Some(absolute_base.clone()); - igtmp.has_git = parent.join(".git").exists(); + igtmp.has_git = + if self.0.opts.git_ignore { + parent.join(".git").exists() + } else { + false + }; ig = Ignore(Arc::new(igtmp)); compiled.insert(parent.as_os_str().to_os_string(), ig.clone()); } @@ -275,6 +280,12 @@ impl Ignore { errs.maybe_push(err); m }; + let has_git = + if self.0.opts.git_ignore { + dir.join(".git").exists() + } else { + false + }; let ig = IgnoreInner { compiled: self.0.compiled.clone(), dir: dir.to_path_buf(), @@ -290,7 +301,7 @@ impl Ignore { git_global_matcher: self.0.git_global_matcher.clone(), git_ignore_matcher: gi_matcher, git_exclude_matcher: gi_exclude_matcher, - has_git: dir.join(".git").exists(), + has_git: has_git, opts: self.0.opts, }; (ig, errs.into_error_option()) -- cgit v1.2.3