summaryrefslogtreecommitdiff
path: root/include/git2/diff.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-07-22 16:07:56 -0700
committerRussell Belfer <rb@github.com>2013-07-22 16:07:56 -0700
commitb4a4cf24a539ce07d86fed6835c98154fb40e723 (patch)
tree74e8807bc0993d480ed38278b4f41cfde83da641 /include/git2/diff.h
parent1cd9dc29b7105cb33959d15ab670a085f5a1445b (diff)
downloadlibgit2-b4a4cf24a539ce07d86fed6835c98154fb40e723.tar.gz
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.
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r--include/git2/diff.h18
1 files changed, 18 insertions, 0 deletions
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
@@ -943,6 +943,24 @@ 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
+ * @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.
*
* Returning a non-zero value from the callback will terminate the iteration