Skip to main content

detect_renames

Function detect_renames 

Source
pub fn detect_renames(
    odb: &Odb,
    work_root: Option<&Path>,
    entries: Vec<DiffEntry>,
    threshold: u32,
) -> Vec<DiffEntry>
Expand description

Detect renames by pairing Deleted and Added entries with similar content.

threshold is the minimum similarity percentage (0–100) for a pair to be considered a rename (Git’s default is 50%). The function reads blob content from the ODB to compute a line-level similarity score.

Exact-OID matches are always 100% similar regardless of content.

When work_root is set, added entries whose new_oid is the zero placeholder (as in uncached diff-index when the work tree diverged from the index) load content from disk under that root instead of the object database.