summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-08-08 08:54:38 -0700
committerBen Straub <bs@github.com>2013-08-08 08:54:38 -0700
commit5e96f31638fe71a0c76805b1352f437881791d98 (patch)
tree45c14d45f24bedd86b494ca76f1e4a26909de8cd /include
parentbf145a6a2f08add441f55387e5ae7daef58187ae (diff)
parenteb1c1707ab6a399734d9083152c05516af052412 (diff)
downloadlibgit2-5e96f31638fe71a0c76805b1352f437881791d98.tar.gz
Merge pull request #1738 from libgit2/diff-patch-content-size
Add API for getting at git_diff_patch->content_size
Diffstat (limited to 'include')
-rw-r--r--include/git2/diff.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 71a8b72bf..c989ba4ee 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -391,7 +391,7 @@ typedef enum {
*/
GIT_DIFF_LINE_FILE_HDR = 'F',
GIT_DIFF_LINE_HUNK_HDR = 'H',
- GIT_DIFF_LINE_BINARY = 'B'
+ GIT_DIFF_LINE_BINARY = 'B' /**< For "Binary files x and y differ" */
} git_diff_line_t;
/**
@@ -943,6 +943,28 @@ GIT_EXTERN(int) git_diff_patch_get_line_in_hunk(
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
+ * @param include_hunk_headers Include hunk header lines if non-zero
+ * @param include_file_headers Include file header lines 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,
+ int include_hunk_headers,
+ int include_file_headers);
+
+/**
* Serialize the patch to text via callback.
*
* Returning a non-zero value from the callback will terminate the iteration