mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 09:40:22 -07:00
ignore: if require_git is false, don't stat .git
I've confirmed via strace that this eliminates a pile of stat calls. PR #2052
This commit is contained in:
parent
ba535fb5a3
commit
009dda1488
@ -202,11 +202,12 @@ impl Ignore {
|
|||||||
errs.maybe_push(err);
|
errs.maybe_push(err);
|
||||||
igtmp.is_absolute_parent = true;
|
igtmp.is_absolute_parent = true;
|
||||||
igtmp.absolute_base = Some(absolute_base.clone());
|
igtmp.absolute_base = Some(absolute_base.clone());
|
||||||
igtmp.has_git = if self.0.opts.git_ignore {
|
igtmp.has_git =
|
||||||
parent.join(".git").exists()
|
if self.0.opts.require_git && self.0.opts.git_ignore {
|
||||||
} else {
|
parent.join(".git").exists()
|
||||||
false
|
} else {
|
||||||
};
|
false
|
||||||
|
};
|
||||||
ig = Ignore(Arc::new(igtmp));
|
ig = Ignore(Arc::new(igtmp));
|
||||||
compiled.insert(parent.as_os_str().to_os_string(), ig.clone());
|
compiled.insert(parent.as_os_str().to_os_string(), ig.clone());
|
||||||
}
|
}
|
||||||
@ -231,7 +232,9 @@ impl Ignore {
|
|||||||
|
|
||||||
/// Like add_child, but takes a full path and returns an IgnoreInner.
|
/// Like add_child, but takes a full path and returns an IgnoreInner.
|
||||||
fn add_child_path(&self, dir: &Path) -> (IgnoreInner, Option<Error>) {
|
fn add_child_path(&self, dir: &Path) -> (IgnoreInner, Option<Error>) {
|
||||||
let git_type = if self.0.opts.git_ignore || self.0.opts.git_exclude {
|
let git_type = if self.0.opts.require_git
|
||||||
|
&& (self.0.opts.git_ignore || self.0.opts.git_exclude)
|
||||||
|
{
|
||||||
dir.join(".git").metadata().ok().map(|md| md.file_type())
|
dir.join(".git").metadata().ok().map(|md| md.file_type())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user