Diff

A diff shows the changes between trees, an index or the working dir.

Examples

# Changes between commits
>>> t0 = revparse_single('HEAD')
>>> t1 = revparse_single('HEAD^')
>>> repo.diff(t0, t1)
>>> t0.diff(t1)           # equivalent
>>> repo.diff('HEAD', 'HEAD^') # equivalent

# Get all patches for a diff
>>> diff = repo.diff('HEAD^', 'HEAD~3')
>>> patches = [p for p in diff]

# Get the stats for a diff
>>> diff = repo.diff('HEAD^', 'HEAD~3')
>>> diff.stats

# Diffing the empty tree
>>> tree = revparse_single('HEAD').tree
>>> tree.diff_to_tree()

# Diff empty tree to a tree
>>> tree = revparse_single('HEAD').tree
>>> tree.diff_to_tree(swap=True)

The Diff type

The Patch type

Attributes:

The DiffDelta type

The DiffFile type

The DiffHunk type

The DiffStats type

The DiffLine type