libgit2

git_patch_from_buffers

Version:

Directly generate a patch from the difference between two buffers.

This is just like git_diff_buffers() except it generates a patch object for the difference instead of directly making callbacks. You can use the standard git_patch accessor functions to read the patch data, and you must call git_patch_free() on the patch when done.

Signature

int git_patch_from_buffers(git_patch **out, const void *old_buffer, size_t old_len, const char *old_as_path, const void *new_buffer, size_t new_len, const char *new_as_path, const git_diff_options *opts);

Parameters

In
out

The generated patch; NULL on error

const void *
In
old_buffer

Raw data for old side of diff, or NULL for empty

size_t
In
old_len

Length of the raw data for old side of the diff

const char *
In
old_as_path

Treat old buffer as if it had this filename; can be NULL

const void *
In
new_buffer

Raw data for new side of diff, or NULL for empty

size_t
In
new_len

Length of raw data for new side of diff

const char *
In
new_as_path

Treat buffer as if it had this filename; can be NULL

In
opts

Options for diff, or NULL for default options

Returns

int

0 on success or error code < 0

Versions