From f6234cd994ad01fb3aa8c2f0fd8e3d2cf89cf3f2 Mon Sep 17 00:00:00 2001 From: Ignacio Casal Quinteiro Date: Fri, 21 Dec 2012 20:57:43 +0100 Subject: Introduce git_diff_blob_to_buffer --- include/git2/diff.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include/git2/diff.h') diff --git a/include/git2/diff.h b/include/git2/diff.h index 760de6fd1..f1c0cd969 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -824,6 +824,30 @@ GIT_EXTERN(int) git_diff_blobs( git_diff_data_cb line_cb, void *payload); +/** + * Directly run a text diff between a blob and a buffer. + * + * Compared to a file, a blob and a buffer lack some contextual information. As such, + * the `git_diff_file` parameters of the callbacks will be filled + * accordingly to the following: `mode` will be set to 0, `path` will be set + * to NULL. When dealing with a NULL blob, `oid` will be set to 0. + * + * When at least the blob or the buffer are binary, the + * `git_diff_delta` binary attribute will be set to 1 and no call to the + * hunk_cb nor line_cb will be made. + * + * @return 0 on success, GIT_EUSER on non-zero callback, or error code + */ +GIT_EXTERN(int) git_diff_blob_to_buffer( + git_blob *old_blob, + char *buffer, + size_t buffer_len, + const git_diff_options *options, + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_data_cb data_cb, + void *payload); + GIT_END_DECL /** @} */ -- cgit v1.2.1