libgit2/rugged — pull request #98 by carlosmn (2012-08-07 23:19:00+00:00)
Title: Initial diff wrapping

So, let's talk API.

It's based on what pygit2 is doing, but with more data.

```ruby
# First get the trees you want to compare
repo = Rugged::Repository.new '.'
tree = repo.lookup repo.head.resolve.target
tree2 = repo.lookup(repo.head.resolve.target).parents[0].tree
# Get the diff object, remember it's old <-> new
diff = tree2.diff tree
# Show a plain-text version of the patch
puts diff.patch
# Or list the files
diff.each_file { |f| puts f[:old_file][:path] }
# Or work per hunk
diff.each_hunk { |h| puts h}
# Or show the data (which you'd want for a colour UI)
diff.each_data {} # Not implemented yet, maybe this one should be the plain .each
```

However, as I've no idea what I'm doing with the ruby extension API, I seem to be getting random trees compared instead of the ones I ask it to.

I'd also like to add an API so you can do `commit.diff` and it diffs the commit's tree with its parent (`git show` basically).