-
-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Support] Create Patch for new file from buffer #742
Comments
Hi, Solution 1 is already there, no?
That said, solution 2 looks good to me, then you can support the optional arguments, old and new filenames. In that case you would wrap |
Developing solution 2 a bit further, it could type check the arguments and wrap:
Then it could be called |
Thanks for the reply, @jdavid. Unfortunately, the solution you highlighted with the empty blob does not work. It creates a patch that is an addition to an empty file, not the creation of a new file (patch should have In either case, glad that there is approval of the second "proper" solution. I'll work on it |
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 usingBlob.diff_to_buffer
.Do you guys have any suggestions? In libgit2, the proper way is to call
git_diff_blob_to_buffer
and set theBlob*
argument toNULL
. 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?
The text was updated successfully, but these errors were encountered: