tree: remove dir argument from TreeDiffIterator::new()

The argument is always the root directory.
This commit is contained in:
Martin von Zweigbergk 2023-07-06 13:25:51 -07:00 committed by Martin von Zweigbergk
parent 1d8e9ec215
commit 7e48033a65

View file

@ -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 }
}