libgit2

git_diff_buffers

Version:

Directly run a diff between two buffers.

Even more than with git_diff_blobs, comparing two buffer lacks context, so the git_diff_file parameters to the callbacks will be faked a la the rules for git_diff_blobs().

Signature

int git_diff_buffers(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 *options, git_diff_file_cb file_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload);

Parameters

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
options

Options for diff, or NULL for default options

In
file_cb

Callback for "file"; made once if there is a diff; can be NULL

In
hunk_cb

Callback for each hunk in diff; can be NULL

In
line_cb

Callback for each line in diff; can be NULL

void *
In
payload

Payload passed to each callback function

Returns

int

0 on success, non-zero callback return value, or error code

Versions