diff options
author | Nicolas Hake <nh@nosebud.de> | 2014-01-22 13:22:15 +0100 |
---|---|---|
committer | Nicolas Hake <nh@nosebud.de> | 2014-01-22 13:40:19 +0100 |
commit | 450e8e9e623b8c172ba4628c146838cbf4c56519 (patch) | |
tree | 06955fb7138124824950dfe04436a10678a1b50c /include/git2/patch.h | |
parent | af2b969b6f63dafa8c55b88cadbcc7631c2dd30b (diff) | |
download | libgit2-450e8e9e623b8c172ba4628c146838cbf4c56519.tar.gz |
Expose patch serialization to git_buf
Returning library-allocated strings from libgit2 works fine on Linux,
but may cause problems on Windows because there is no one C Runtime that
everything links against. With libgit2 not exposing its own allocator,
freeing the string is a gamble.
git_patch_to_str already serializes to a buffer, then returns the
underlying memory. Expose the functionality directly, so callers can use
the git_buf_free function to free the memory later.
Diffstat (limited to 'include/git2/patch.h')
-rw-r--r-- | include/git2/patch.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/git2/patch.h b/include/git2/patch.h index e09f625c0..e5dd5d8d4 100644 --- a/include/git2/patch.h +++ b/include/git2/patch.h @@ -242,6 +242,16 @@ GIT_EXTERN(int) git_patch_to_str( char **string, git_patch *patch); +/** + * Get the content of a patch as a single diff text. + * + * @param out The git_buf to be filled in + * @param patch A git_patch representing changes to one file + * @return 0 on success, <0 on failure. + */ +GIT_EXTERN(int) git_patch_to_buf( + git_buf *out, + git_patch *patch); GIT_END_DECL |