gix_diff

Function tree

source
pub fn tree<StateMut>(
    lhs: TreeRefIter<'_>,
    rhs: TreeRefIter<'_>,
    state: StateMut,
    objects: impl Find,
    delegate: &mut impl Visit,
) -> Result<(), Error>
where StateMut: BorrowMut<State>,
Expand description

Calculate the changes that would need to be applied to lhs to get rhs using objects to obtain objects as needed for traversal. state can be used between multiple calls to re-use memory.

  • The state maybe owned or mutably borrowed to allow reuses allocated data structures through multiple runs.
  • delegate will receive the computed changes, see the Visit trait for more information on what to expect.

§Notes

  • lhs can be an empty tree to simulate what would happen if the left-hand side didn’t exist.
  • To obtain progress, implement it within the delegate.
  • Tree entries are expected to be ordered using tree-entry-comparison (the same in Rust)
  • it does a breadth first iteration as buffer space only fits two trees, the current one on the one we compare with.
  • does not do rename tracking but attempts to reduce allocations to zero (so performance is mostly determined by the delegate implementation which should be as specific as possible. Rename tracking can be computed on top of the changes received by the delegate.
  • cycle checking is not performed, but can be performed in the delegate which can return tree::visit::Action::Cancel to stop the traversal.