diff: Cache object by content, not location
diff: Cache object by content, not location

Diff objects (deltas and hunks) from libgit2 are cached in a hash
table, using object's memory locations as keys. In some cases,
libgit2 does not generate new delta and hunk objects but simply
modify its first allocated struct in place. git_diff_blob_to_buffer()
function does so for hunks, for example, thus breaking the memory
location based index logic of libgit2-glib.

This patch makes the index logic rely on actual object's content
instead of memory location. Index for deltas are generated from
'old_file' git oid. Index for hunks are generated from a combination
of its belonging delta's 'old_file' git oid and its own header.

https://bugzilla.gnome.org/show_bug.cgi?id=792733
https://gitlab.gnome.org/GNOME/gitg/issues/109

GNOME/libgit2-glib,GNOME/libgit2-glib