
Now Repository.head behaves like libgit2's git_repository_head, it returns the resolved reference. These two lines are equivalent: ref = repo.head ref = repo.lookup_reference('HEAD').resolve() Before it returned a commit.
1.2 KiB
1.2 KiB
Diff
A diff shows the changes between trees, an index or the working dir:
>>> head = repo.revparse_single('HEAD')
# Diff two trees
>>> t0 = head.tree
>>> t1 = head.parents[0].tree
>>> diff = t1.diff(t0)
# Diff a tree with the index
>>> diff = head.tree.diff(repo.index)
# Diff a tree with the current working dir
>>> diff = head.tree.diff()
The Diff type
pygit2.Diff.patch
pygit2.Diff.merge
pygit2.Diff.find_similar
The Patch type
pygit2.Patch.old_file_path
pygit2.Patch.new_file_path
pygit2.Patch.old_oid
pygit2.Patch.new_oid
pygit2.Patch.status
pygit2.Patch.similarity
pygit2.Patch.hunks
The Hunk type
pygit2.Hunk.old_start
pygit2.Hunk.old_lines
pygit2.Hunk.new_start
pygit2.Hunk.new_lines
pygit2.Hunk.lines