summaryrefslogtreecommitdiff
path: root/include/git2/patch.h
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-02-28 09:40:17 +0100
committerVicent Marti <vicent@github.com>2014-02-28 09:40:17 +0100
commit06d41826b6f85d83e68973e0565978b6b3e8976f (patch)
tree74ca53d8808a16090bb4df867b38c4a07444f8e1 /include/git2/patch.h
parent1574d3884f020c072f68c08785e199732e438e34 (diff)
parent6789b7a75d1e24a7f4ce34628c6b4561517f0b73 (diff)
downloadlibgit2-06d41826b6f85d83e68973e0565978b6b3e8976f.tar.gz
Merge pull request #2146 from libgit2/rb/diff-b2b
Add git_diff_buffers and git_patch_from_buffers
Diffstat (limited to 'include/git2/patch.h')
-rw-r--r--include/git2/patch.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/git2/patch.h b/include/git2/patch.h
index 1eca29d4a..f5ec682c6 100644
--- a/include/git2/patch.h
+++ b/include/git2/patch.h
@@ -106,6 +106,34 @@ GIT_EXTERN(int) git_patch_from_blob_and_buffer(
const git_diff_options *opts);
/**
+ * Directly generate a patch from the difference between two buffers.
+ *
+ * This is just like `git_diff_buffers()` except it generates a patch
+ * object for the difference instead of directly making callbacks. You can
+ * use the standard `git_patch` accessor functions to read the patch
+ * data, and you must call `git_patch_free()` on the patch when done.
+ *
+ * @param out The generated patch; NULL on error
+ * @param old_buffer Raw data for old side of diff, or NULL for empty
+ * @param old_len Length of the raw data for old side of the diff
+ * @param old_as_path Treat old buffer as if it had this filename; can be NULL
+ * @param new_buffer Raw data for new side of diff, or NULL for empty
+ * @param new_len Length of raw data for new side of diff
+ * @param new_as_path Treat buffer as if it had this filename; can be NULL
+ * @param opts Options for diff, or NULL for default options
+ * @return 0 on success or error code < 0
+ */
+GIT_EXTERN(int) git_patch_from_buffers(
+ git_patch **out,
+ const void *old_buffer,
+ size_t old_len,
+ const char *old_as_path,
+ const char *new_buffer,
+ size_t new_len,
+ const char *new_as_path,
+ const git_diff_options *opts);
+
+/**
* Free a git_patch object.
*/
GIT_EXTERN(void) git_patch_free(git_patch *patch);