From 7e48033a65065ee979da93a043afaf1bfb4a16e9 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 6 Jul 2023 13:25:51 -0700 Subject: [PATCH] tree: remove `dir` argument from `TreeDiffIterator::new()` The argument is always the root directory. --- lib/src/tree.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/src/tree.rs b/lib/src/tree.rs index d3b16c4fd..62809ec49 100644 --- a/lib/src/tree.rs +++ b/lib/src/tree.rs @@ -187,7 +187,7 @@ impl Tree { other: &Tree, matcher: &'matcher dyn Matcher, ) -> TreeDiffIterator<'matcher> { - TreeDiffIterator::new(RepoPath::root(), self.clone(), other.clone(), matcher) + TreeDiffIterator::new(self.clone(), other.clone(), matcher) } pub fn diff_summary(&self, other: &Tree, matcher: &dyn Matcher) -> DiffSummary { @@ -379,10 +379,13 @@ enum TreeDiffItem { } impl<'matcher> TreeDiffIterator<'matcher> { - fn new(dir: RepoPath, tree1: Tree, tree2: Tree, matcher: &'matcher dyn Matcher) -> Self { + fn new(tree1: Tree, tree2: Tree, matcher: &'matcher dyn Matcher) -> Self { + let root_dir = RepoPath::root(); let mut stack = Vec::new(); - if !matcher.visit(&dir).is_nothing() { - stack.push(TreeDiffItem::Dir(TreeDiffDirItem::new(dir, tree1, tree2))); + if !matcher.visit(&root_dir).is_nothing() { + stack.push(TreeDiffItem::Dir(TreeDiffDirItem::new( + root_dir, tree1, tree2, + ))); }; Self { stack, matcher } }