Contents
A diff shows the changes between trees, an index or the working dir.
Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, or changes between two blobs.
Keyword arguments:
Examples:
# Changes in the working tree not yet staged for the next commit
>>> diff()
# Changes between the index and your last commit
>>> diff(cached=True)
# Changes in the working tree since your last commit
>>> diff('HEAD')
# Changes between commits
>>> t0 = revparse_single('HEAD')
>>> t1 = revparse_single('HEAD^')
>>> diff(t0, t1)
>>> diff('HEAD', 'HEAD^') # equivalent
If you want to diff a tree against an empty tree, use the low level API (Tree.diff_to_tree()) directly.
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]
# 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)
Patch diff string.
Returns the number of deltas/patches in this diff.
Merge one diff into another.
Find renamed files in diff and updates them in-place in the diff itself.
Attributes:
old file path
new file path
old oid
new oid
status
similarity
hunks
additions
deletions
Getters:
True if binary data, False if not.