Don't initialize ignores for file arguments.

We'll never use them, so it's wasted effort.
This commit is contained in:
Andrew Gallant 2016-09-26 18:43:15 -04:00
parent b8c7864a02
commit 2da0eab2b8

View File

@ -673,15 +673,20 @@ impl Args {
pub fn walker(&self, path: &Path) -> Result<walk::Iter> { pub fn walker(&self, path: &Path) -> Result<walk::Iter> {
let wd = WalkDir::new(path).follow_links(self.follow); let wd = WalkDir::new(path).follow_links(self.follow);
let mut ig = Ignore::new(); let mut ig = Ignore::new();
ig.ignore_hidden(!self.hidden); // Only register ignore rules if this is a directory. If it's a file,
ig.no_ignore(self.no_ignore); // then it was explicitly given by the end user, so we always search
ig.no_ignore_vcs(self.no_ignore_vcs); // it.
ig.add_types(self.types.clone()); if path.is_dir() {
if !self.no_ignore_parent { ig.ignore_hidden(!self.hidden);
try!(ig.push_parents(path)); ig.no_ignore(self.no_ignore);
} ig.no_ignore_vcs(self.no_ignore_vcs);
if let Some(ref overrides) = self.glob_overrides { ig.add_types(self.types.clone());
ig.add_override(overrides.clone()); if !self.no_ignore_parent {
try!(ig.push_parents(path));
}
if let Some(ref overrides) = self.glob_overrides {
ig.add_override(overrides.clone());
}
} }
Ok(walk::Iter::new(ig, wd)) Ok(walk::Iter::new(ig, wd))
} }