diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-05-29 18:06:11 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-05-29 18:06:11 -0400 |
commit | 7d3f79458891d2cb9ce2b3d51f8d8f788d36c9e8 (patch) | |
tree | f55212d16f3d27c0aa4ffeb4d5e10f82516c897c | |
parent | 290fd2a7b6b21401c0b6fd51de75bd4f53091577 (diff) |
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.
-rw-r--r-- | ignore/src/dir.rs | 15 |
1 files 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()) |