Description
Hello all,
I am working with the use case of creating diffs from buffers. Everything is going well as there is decent support for it, especially in the form of Blob.diff_to_buffer
. The function works great when changing content and will soon work for deleting a file (In #741). However, I cannot figure out a proper way to add files using Blob.diff_to_buffer
.
Do you guys have any suggestions? In libgit2, the proper way is to call git_diff_blob_to_buffer
and set the Blob*
argument to NULL
. However, pygit2 does not have a static function to be able to do this. Do you guys have any suggestions? Here are things I can think of:
-
Create a special "Empty" blob object (or give it an
exists
property) that can be used to signify a nonexistent blob and then dodiff_to_buffer
on that. -
Expose a static
Patch.from_blob_to_buffer()
which can then be called likePatch.from_blob_to_buffer(None, buf)
.
The other thing I can think of, which does not yet exist, is adding a Tree.diff_to_buffer()
/Tree.diff_to_blob()
to libgit2, which would solve this problem since the Tree would know whether the blob is being added or removed. (Of course, this would then have to be wrapped in pygit2)
Thoughts?