libgit2

git_diff_blob_to_buffer

Version:

Directly run a diff between a blob and a buffer.

As with git_diff_blobs, comparing a blob and buffer lacks some context, so the git_diff_file parameters to the callbacks will be faked a la the rules for git_diff_blobs().

Passing NULL for old_blob will be treated as an empty blob (i.e. the file_cb will be invoked with GIT_DELTA_ADDED and the diff will be the entire content of the buffer added). Passing NULL to the buffer will do the reverse, with GIT_DELTA_REMOVED and blob content removed.

Signature

int git_diff_blob_to_buffer(const git_blob *old_blob, const char *old_as_path, const char *buffer, size_t buffer_len, const char *buffer_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

In
old_blob

Blob for old side of diff, or NULL for empty blob

const char *
In
old_as_path

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

const char *
In
buffer

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

size_t
In
buffer_len

Length of raw data for new side of diff

const char *
In
buffer_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