diff options
author | Russell Belfer <rb@github.com> | 2012-10-25 11:48:39 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-10-25 11:48:39 -0700 |
commit | cb7180a6e2bb7e5912c16d2109f273c75731a607 (patch) | |
tree | 24ab45a03ba348cce9ba237856b462d6e1b09dec /include/git2/diff.h | |
parent | 3943dc78a5c67c1db367c4e13a79884ef72f7f3b (diff) | |
download | libgit2-cb7180a6e2bb7e5912c16d2109f273c75731a607.tar.gz |
Add git_diff_patch_print
This adds a `git_diff_patch_print()` API which is more like the
existing API to "print" a patch from an entire `git_diff_list`
but operates on a single `git_diff_patch` object.
Also, it rewrites the `git_diff_patch_to_str()` API to use that
function (making it very small).
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r-- | include/git2/diff.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h index 1c2a2f83a..4e80bed56 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -604,10 +604,27 @@ GIT_EXTERN(int) git_diff_patch_get_line_in_hunk( size_t line_of_hunk); /** + * Serialize the patch to text via callback. + * + * Returning a non-zero value from the callback will terminate the iteration + * and cause this return `GIT_EUSER`. + * + * @param patch A git_diff_patch representing changes to one file + * @param cb_data Reference pointer that will be passed to your callbacks. + * @param print_cb Callback function to output lines of the patch. Will be + * called for file headers, hunk headers, and diff lines. + * @return 0 on success, GIT_EUSER on non-zero callback, or error code + */ +GIT_EXTERN(int) git_diff_patch_print( + git_diff_patch *patch, + void *cb_data, + git_diff_data_fn print_cb); + +/** * Get the content of a patch as a single diff text. * * @param string Allocated string; caller must free. - * @param patch The patch to generate a string from. + * @param patch A git_diff_patch representing changes to one file * @return 0 on success, <0 on failure. */ GIT_EXTERN(int) git_diff_patch_to_str( |