libgit2

git_diff_print_patch

Version:

Iterate over a diff generating text output like "git diff".

This is a super easy way to generate a patch from a diff.

Returning a non-zero value from the callbacks will terminate the iteration and cause this return GIT_EUSER.

Signature

int git_diff_print_patch(git_diff_list *diff, git_diff_data_cb print_cb, void *payload);

Parameters

In
diff

A git_diff_list generated by one of the above functions.

In
print_cb

Callback function to output lines of the diff. This same function will be called for file headers, hunk headers, and diff lines. Fortunately, you can probably use various GIT_DIFF_LINE constants to determine what text you are given.

void *
In
payload

Reference pointer that will be passed to your callbacks.

Returns

int

0 on success, GIT_EUSER on non-zero callback, or error code

Versions