diff options
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r-- | include/git2/diff.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h index c0d42e30e..0ecdc1bed 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -426,6 +426,53 @@ typedef int (*git_diff_file_cb)( void *payload); /** + * When producing a binary diff, the binary data returned will be + * either the deflated full ("literal") contents of the file, or + * the deflated binary delta between the two sides (whichever is + * smaller). + */ +typedef enum { + /** There is no binary delta. */ + GIT_DIFF_BINARY_NONE, + + /** The binary data is the literal contents of the file. */ + GIT_DIFF_BINARY_LITERAL, + + /** The binary data is the delta from one side to the other. */ + GIT_DIFF_BINARY_DELTA, +} git_diff_binary_t; + +/** The contents of one of the files in a binary diff. */ +typedef struct { + /** The type of binary data for this file. */ + git_diff_binary_t type; + + /** The binary data, deflated. */ + const char *data; + + /** The length of the binary data. */ + size_t datalen; + + /** The length of the binary data after inflation. */ + size_t inflatedlen; +} git_diff_binary_file; + +/** Structure describing the binary contents of a diff. */ +typedef struct { + git_diff_binary_file old_file; /**< The contents of the old file. */ + git_diff_binary_file new_file; /**< The contents of the new file. */ +} git_diff_binary; + +/** +* When iterating over a diff, callback that will be made for +* binary content within the diff. +*/ +typedef int(*git_diff_binary_cb)( + const git_diff_delta *delta, + const git_diff_binary *binary, + void *payload); + +/** * Structure describing a hunk of a diff. */ typedef struct { @@ -897,6 +944,7 @@ GIT_EXTERN(int) git_diff_is_sorted_icase(const git_diff *diff); * * @param diff A git_diff generated by one of the above functions. * @param file_cb Callback function to make per file in the diff. + * @param binary_cb Optional callback to make for binary files. * @param hunk_cb Optional callback to make per hunk of text diff. This * callback is called to describe a range of lines in the * diff. It will not be issued for binary files. @@ -909,6 +957,7 @@ GIT_EXTERN(int) git_diff_is_sorted_icase(const git_diff *diff); GIT_EXTERN(int) git_diff_foreach( git_diff *diff, git_diff_file_cb file_cb, + git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); @@ -984,6 +1033,7 @@ GIT_EXTERN(int) git_diff_print( * @param new_as_path Treat new blob as if it had this filename; can be NULL * @param options Options for diff, or NULL for default options * @param file_cb Callback for "file"; made once if there is a diff; can be NULL + * @param binary_cb Callback for binary files; can be NULL * @param hunk_cb Callback for each hunk in diff; can be NULL * @param line_cb Callback for each line in diff; can be NULL * @param payload Payload passed to each callback function @@ -996,6 +1046,7 @@ GIT_EXTERN(int) git_diff_blobs( const char *new_as_path, const git_diff_options *options, git_diff_file_cb file_cb, + git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); @@ -1019,6 +1070,7 @@ GIT_EXTERN(int) git_diff_blobs( * @param buffer_as_path Treat buffer as if it had this filename; can be NULL * @param options Options for diff, or NULL for default options * @param file_cb Callback for "file"; made once if there is a diff; can be NULL + * @param binary_cb Callback for binary files; can be NULL * @param hunk_cb Callback for each hunk in diff; can be NULL * @param line_cb Callback for each line in diff; can be NULL * @param payload Payload passed to each callback function @@ -1032,6 +1084,7 @@ GIT_EXTERN(int) git_diff_blob_to_buffer( const char *buffer_as_path, const git_diff_options *options, git_diff_file_cb file_cb, + git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); @@ -1051,6 +1104,7 @@ GIT_EXTERN(int) git_diff_blob_to_buffer( * @param new_as_path Treat buffer as if it had this filename; can be NULL * @param options Options for diff, or NULL for default options * @param file_cb Callback for "file"; made once if there is a diff; can be NULL + * @param binary_cb Callback for binary files; can be NULL * @param hunk_cb Callback for each hunk in diff; can be NULL * @param line_cb Callback for each line in diff; can be NULL * @param payload Payload passed to each callback function @@ -1065,6 +1119,7 @@ GIT_EXTERN(int) git_diff_buffers( const char *new_as_path, const git_diff_options *options, git_diff_file_cb file_cb, + git_diff_binary_cb binary_cb, git_diff_hunk_cb hunk_cb, git_diff_line_cb line_cb, void *payload); |