Skip to content

Commit

Permalink
merged_tree: leverage .to_tree_merge() in TreeDiffIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Aug 8, 2024
1 parent 6fc7cec commit 19b62d2
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions lib/src/merged_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,25 +622,14 @@ impl<'matcher> TreeDiffIterator<'matcher> {
}
}

fn single_tree(
store: &Arc<Store>,
dir: &RepoPath,
value: Option<&TreeValue>,
) -> BackendResult<Tree> {
match value {
Some(TreeValue::Tree(tree_id)) => store.get_tree(dir, tree_id),
_ => Ok(Tree::null(store.clone(), dir.to_owned())),
}
}

/// Gets the given tree if `value` is a tree, otherwise an empty tree.
fn trees(
store: &Arc<Store>,
dir: &RepoPath,
values: &MergedTreeValue,
) -> BackendResult<Merge<Tree>> {
if values.is_tree() {
values.try_map(|value| Self::single_tree(store, dir, value.as_ref()))
if let Some(trees) = values.to_tree_merge(store, dir)? {
Ok(trees)
} else {
Ok(Merge::resolved(Tree::null(store.clone(), dir.to_owned())))
}
Expand Down

0 comments on commit 19b62d2

Please sign in to comment.