Skip to main content

compare

Function compare 

Source
pub fn compare(
    git: &dyn GitServe,
    hash: Kind,
    old_tree: Option<ObjectId>,
    new_tree: Option<ObjectId>,
    path_prefixes: &[String],
) -> Result<Vec<FileChange>, DiffError>
Expand description

Compare two trees and report every path that differs.

path_prefixes is a filter in the caller’s terms: a change is reported when its path starts with any of them, and an empty list means everything. The walk prunes on it as well as filtering — a directory that no prefix can reach is never read — which is what keeps a one-file diff of a large repository a one-file cost.

The output is ordered by path, because the walk is: BTreeMap at every level and depth-first in name order. A caller that sorted the result again would be sorting a sorted list, and a caller that relied on insertion order would be relying on nothing.