libgit2

git_diff_blobs

Version:

Directly run a diff on two blobs.

Compared to a file, a blob lacks some contextual information. As such, the git_diff_file given to the callback will have some fake data; i.e. mode will be 0 and path will be NULL.

NULL is allowed for either old_blob or new_blob and will be treated as an empty blob, with the oid set to NULL in the git_diff_file data. Passing NULL for both blobs is a noop; no callbacks will be made at all.

We do run a binary content check on the blob content and if either blob looks like binary data, the git_diff_delta binary attribute will be set to 1 and no call to the hunk_cb nor line_cb will be made (unless you pass GIT_DIFF_FORCE_TEXT of course).

Signature

int git_diff_blobs(const git_blob *old_blob, const char *old_as_path, const git_blob *new_blob, 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

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

In
new_blob

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

const char *
In
new_as_path

Treat new blob 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