summaryrefslogtreecommitdiff
path: root/include/git2/diff.h
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-10-30 12:04:28 -0700
committerVicent Martí <vicent@github.com>2012-10-30 12:04:28 -0700
commitefde422553e1181933d0bc9d7112740e858a847b (patch)
treee48cf99ea2d89a0240597fd6e7eb61082bbc6f5b /include/git2/diff.h
parentc4a9ded0f9d8edd400cce0df5901af5b8c103147 (diff)
parentcb7180a6e2bb7e5912c16d2109f273c75731a607 (diff)
downloadlibgit2-efde422553e1181933d0bc9d7112740e858a847b.tar.gz
Merge pull request #1017 from arrbee/diff-patch-to-str
Add git_diff_patch_to_str API
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r--include/git2/diff.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 1932db029..4e80bed56 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -603,6 +603,34 @@ GIT_EXTERN(int) git_diff_patch_get_line_in_hunk(
size_t hunk_idx,
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 A git_diff_patch representing changes to one file
+ * @return 0 on success, <0 on failure.
+ */
+GIT_EXTERN(int) git_diff_patch_to_str(
+ char **string,
+ git_diff_patch *patch);
+
/**@}*/