libgit2/pygit2 — pull request #91 by cholin (2012-05-24 17:33:57+00:00)
Title: basic diff implementation

Hey.

The following pull request has some rudimentary diff support for pygit2. You can now compare two trees and get a changeset of them. The changeset contains informations about which files have been changed, as well hunks for every change and a patch for the whole changeset.

Here a small example:

```from pygit2 import Repository

repo = Repository('.')
head = repo.lookup_reference('HEAD').resolve()
commit = repo[head.oid]
diff = commit.tree.diff(commit.parents[0].tree)
changes = diff.changes

print("Changed files:")
for v in changes['files']:
print("* %s -> %s (%d)" % v)

print("Hunks:")
for h in changes['hunks']:
hunk = (h.new_start, h.new_lines, h.old_start, h.old_lines)
print("* @@ %d,%d %d,%d@@" % hunk)
#print(h.old_data.decode('utf-8'))
#print(h.new_data.decode('utf-8'))

print(diff.patch.decode('utf-8'))
```

Does anyone has some feedback?