From b4a4cf24a539ce07d86fed6835c98154fb40e723 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 22 Jul 2013 16:07:56 -0700 Subject: Add git_diff_patch_size() API This adds a new API to get the size in bytes of the diffs in a git_diff_patch object. --- include/git2/diff.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/git2/diff.h') diff --git a/include/git2/diff.h b/include/git2/diff.h index 71a8b72bf..711967501 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -942,6 +942,24 @@ GIT_EXTERN(int) git_diff_patch_get_line_in_hunk( size_t hunk_idx, size_t line_of_hunk); +/** + * Look up size of patch diff data in bytes + * + * This returns the raw size of the patch data. This only includes the + * actual data from the lines of the diff, not the file or hunk headers. + * + * If you pass `include_context` as true (non-zero), this will be the size + * of all of the diff output; if you pass it as false (zero), this will + * only include the actual changed lines (as if `context_lines` was 0). + * + * @param patch A git_diff_patch representing changes to one file + * @param include_context Include context lines in size if non-zero + * @return The number of bytes of data + */ +GIT_EXTERN(size_t) git_diff_patch_size( + git_diff_patch *patch, + int include_context); + /** * Serialize the patch to text via callback. * -- cgit v1.2.1