summaryrefslogtreecommitdiff
path: root/include/git2/diff.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-07-23 14:34:31 -0700
committerRussell Belfer <rb@github.com>2013-07-23 14:34:31 -0700
commit197b8966dba18770e4b77a17173c8f354ac175e3 (patch)
tree773f3621e87acf5543bb0443f8f1ba0437c78719 /include/git2/diff.h
parentb4a4cf24a539ce07d86fed6835c98154fb40e723 (diff)
downloadlibgit2-197b8966dba18770e4b77a17173c8f354ac175e3.tar.gz
Add hunk/file headers to git_diff_patch_size
This allows git_diff_patch_size to account for hunk headers and file headers in the returned size. This required some refactoring of the code that is used to print file headers so that it could be invoked by the git_diff_patch_size API. Also this increases the test coverage and fixes an off-by-one bug in the size calculation when newline changes happen at the end of the file.
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r--include/git2/diff.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 711967501..269eb773d 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' /**< Deprecated, will not be returned */
} git_diff_line_t;
/**
@@ -954,11 +954,15 @@ GIT_EXTERN(int) git_diff_patch_get_line_in_hunk(
*
* @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_context,
+ int include_hunk_headers,
+ int include_file_headers);
/**
* Serialize the patch to text via callback.