Skip to main content

diff_trees

Function diff_trees 

Source
pub fn diff_trees(old_tree: &FileTree, new_tree: &FileTree) -> Vec<DiffEntry>
Expand description

Compute the diff between two FileTrees.

Returns a list of DiffEntry describing all changes. The entries are sorted by path for deterministic output.

§Algorithm

  1. Files only in old_tree → Deleted
  2. Files only in new_tree → Added
  3. Files in both with same hash → Unchanged (omitted)
  4. Files in both with different hash → Modified
  5. Heuristic rename detection: a deleted file whose hash matches an added file is reported as a rename.