Skip to main content

Module diff

Module diff 

Source
Available on crate feature diff only.
Expand description

A module for computing diffs between git trees

§Usage

First, construct a TreeDiff object, which walks the specified trees and finds differing files. Then, use TreeDiff::to_text_diff to perform a line-by-line diff on each differing file.

§Example

async fn get_diff<F: FileSystem>(repo: &Repo<F>, left: &Tree, right: &Tree) -> GResult<Diff> {
    let tree_diff = TreeDiff::new(repo, left, right).await?;
    tree_diff.to_text_diff(repo).await
}

§Notes

This algorithm is relatively naive, in that it simply loads each object in full and then computes their diff. You will find that using git diff on the command line is much faster. This is likely because because git diff may be aware of the packfile delta encoding and may use it to compute efficient diffs.

Structs§

Diff
A “full” diff, i.e. one which encapsulates line changes between files
Path
A path for a file in a diff
TreeDiff
A diff of git trees, holding the ObjectIds of differing files

Enums§

DiffEntry
Represents a diff of a single file