summaryrefslogtreecommitdiff
path: root/include/git2/diff.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-02-27 14:13:22 -0800
committerRussell Belfer <rb@github.com>2014-02-27 14:13:22 -0800
commit6789b7a75d1e24a7f4ce34628c6b4561517f0b73 (patch)
tree74ca53d8808a16090bb4df867b38c4a07444f8e1 /include/git2/diff.h
parentd88399922f622baef91c6f4e4e67b2091653cb65 (diff)
downloadlibgit2-6789b7a75d1e24a7f4ce34628c6b4561517f0b73.tar.gz
Add buffer to buffer diff and patch APIs
This adds `git_diff_buffers` and `git_patch_from_buffers`. This also includes a bunch of internal refactoring to increase the shared code between these functions and the blob-to-blob and blob-to-buffer APIs, as well as some higher level assert helpers in the tests to also remove redundancy.
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r--include/git2/diff.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index a3cdd8193..943e2ec4c 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -1013,6 +1013,39 @@ GIT_EXTERN(int) git_diff_blob_to_buffer(
git_diff_line_cb line_cb,
void *payload);
+/**
+ * Directly run a diff between two buffers.
+ *
+ * Even more than with `git_diff_blobs`, comparing two buffer lacks
+ * context, so the `git_diff_file` parameters to the callbacks will be
+ * faked a la the rules for `git_diff_blobs()`.
+ *
+ * @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 options Options for diff, or NULL for default options
+ * @param file_cb Callback for "file"; made once if there is a diff; can be NULL
+ * @param hunk_cb Callback for each hunk in diff; can be NULL
+ * @param line_cb Callback for each line in diff; can be NULL
+ * @param payload Payload passed to each callback function
+ * @return 0 on success, non-zero callback return value, or error code
+ */
+GIT_EXTERN(int) git_diff_buffers(
+ const void *old_buffer,
+ size_t old_len,
+ const char *old_as_path,
+ const void *new_buffer,
+ size_t new_len,
+ const char *new_as_path,
+ const git_diff_options *options,
+ git_diff_file_cb file_cb,
+ git_diff_hunk_cb hunk_cb,
+ git_diff_line_cb line_cb,
+ void *payload);
+
GIT_END_DECL