PyObject * Blob_diff_to_buffer(Blob *self, PyObject *args, PyObject *kwds) { git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_patch *patch; char *old_as_path = NULL, *buffer_as_path = NULL; const char *buffer = NULL; Py_ssize_t buffer_len; int err; char *keywords[] = {"buffer", "flag", "old_as_path", "buffer_as_path", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|s#ssI", keywords, &buffer, &buffer_len, &opts.flags, &old_as_path, &buffer_as_path)) return NULL; err = git_patch_from_blob_and_buffer(&patch, self->blob, old_as_path, buffer, buffer_len, buffer_as_path, &opts); if (err < 0) return Error_set(err); return wrap_patch(patch); }
PyObject* diff_get_patch_byindex(git_diff *diff, size_t idx) { git_patch *patch = NULL; int err; err = git_patch_from_diff(&patch, diff, idx); if (err < 0) return Error_set(err); return (PyObject*) wrap_patch(patch); }
PyObject * Blob_diff(Blob *self, PyObject *args, PyObject *kwds) { git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_patch *patch; char *old_as_path = NULL, *new_as_path = NULL; Blob *py_blob = NULL; int err; char *keywords[] = {"blob", "flag", "old_as_path", "new_as_path", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!ssI", keywords, &BlobType, &py_blob, &opts.flags, &old_as_path, &new_as_path)) return NULL; err = git_patch_from_blobs(&patch, self->blob, old_as_path, py_blob ? py_blob->blob : NULL, new_as_path, &opts); if (err < 0) return Error_set(err); return wrap_patch(patch); }