1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
**********************************************************************
Diff
**********************************************************************
.. contents::
A diff shows the changes between trees, an index or the working dir.
.. automethod:: pygit2.Repository.diff
Examples
.. code-block:: python
# 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
====================
.. autoclass:: pygit2.Diff
:members: deltas, find_similar, merge, parse_diff, patch, patchid, stats
.. method:: Diff.__iter__()
Returns an iterator over the deltas/patches in this diff.
.. method:: Diff.__len__()
Returns the number of deltas/patches in this diff.
The Patch type
====================
Attributes:
.. autoclass:: pygit2.Patch
:members: create_from, data, delta, hunks, line_stats, text
The DiffDelta type
====================
.. autoclass:: pygit2.DiffDelta
:members:
The DiffFile type
====================
.. autoclass:: pygit2.DiffFile
:members:
The DiffHunk type
====================
.. autoclass:: pygit2.DiffHunk
:members:
The DiffStats type
====================
.. autoclass:: pygit2.DiffStats
:members:
The DiffLine type
====================
.. autoclass:: pygit2.DiffLine
:members:
|