diff options
author | Russell Belfer <rb@github.com> | 2014-02-27 14:13:22 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-02-27 14:13:22 -0800 |
commit | 6789b7a75d1e24a7f4ce34628c6b4561517f0b73 (patch) | |
tree | 74ca53d8808a16090bb4df867b38c4a07444f8e1 /include/git2/patch.h | |
parent | d88399922f622baef91c6f4e4e67b2091653cb65 (diff) | |
download | libgit2-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/patch.h')
-rw-r--r-- | include/git2/patch.h | 28 |
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); |