libgit2

git_diff_foreach

Version:

Loop over all deltas in a diff issuing callbacks.

This will iterate through all of the files described in a diff. You should provide a file callback to learn about each file.

The "hunk" and "line" callbacks are optional, and the text diff of the files will only be calculated if they are not NULL. Of course, these callbacks will not be invoked for binary files on the diff or for files whose only changed is a file mode change.

Returning a non-zero value from any of the callbacks will terminate the iteration and return the value to the user.

Signature

int git_diff_foreach(git_diff *diff, git_diff_file_cb file_cb, git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload);

Parameters

In
diff

A git_diff generated by one of the above functions.

In
file_cb

Callback function to make per file in the diff.

In
binary_cb

Optional callback to make for binary files.

In
hunk_cb

Optional callback to make per hunk of text diff. This callback is called to describe a range of lines in the diff. It will not be issued for binary files.

In
line_cb

Optional callback to make per line of diff text. This same callback will be made for context lines, added, and removed lines, and even for a deleted trailing newline.

void *
In
payload

Reference pointer that will be passed to your callbacks.

Returns

int

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

Versions