Expand description
Diff machinery — compare trees, index entries, and working tree files.
§Overview
This module provides the core diffing infrastructure shared by diff,
diff-index, status, log, show, commit, and merge.
§Levels of comparison
- Tree-to-tree — compare two tree objects (e.g. for
log/show). - Tree-to-index — compare a tree (usually HEAD) against the index
(staged changes, used by
diff --cachedandstatus). - Index-to-worktree — compare index against the working directory
(unstaged changes, used by
diffandstatus).
§Content diff
Line-level diffing uses the Myers algorithm via the similar crate.
Output formats: unified patch, raw (:old-mode new-mode ...), stat,
numstat.
Structs§
- Diff
Entry - A single diff entry representing one changed path.
Enums§
- Diff
Status - The kind of change between two sides of a diff.
Constants§
- ZERO_
OID - The zero (null) object ID used for “no object” in diff output.
Functions§
- count_
changes - Count insertions and deletions between two strings.
- detect_
copies - Detect copies among diff entries.
- detect_
renames - Detect renames by pairing Deleted and Added entries with similar content.
- diff_
index_ to_ tree - Compare the index against a tree (usually HEAD’s tree).
- diff_
index_ to_ worktree - Compare the index against the working tree.
- diff_
tree_ to_ worktree - Compare a tree against the working tree.
- diff_
trees - Compare two trees and return the list of changed entries.
- format_
raw - Format a diff entry in Git’s raw diff format.
- format_
raw_ abbrev - Format a diff entry with abbreviated OIDs.
- format_
rename_ path - Format a rename pair using Git’s compact path format.
- format_
stat_ line - Generate diff stat output (file name + insertions/deletions).
- stat_
matches - Quick stat check: does the index entry’s cached stat data match the file?
- unified_
diff - Generate a unified diff patch for two blobs.
- zero_
oid - Return the zero ObjectId.