diff options
Diffstat (limited to 'include/git2/diff.h')
-rw-r--r-- | include/git2/diff.h | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/include/git2/diff.h b/include/git2/diff.h index 47bfa5f69..fd00378af 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -106,6 +106,7 @@ typedef enum { * - max_size: maximum blob size to diff, above this treated as binary */ typedef struct { + unsigned int version; /**< version for the struct */ uint32_t flags; /**< defaults to GIT_DIFF_NORMAL */ uint16_t context_lines; /**< defaults to 3 */ uint16_t interhunk_lines; /**< defaults to 0 */ @@ -186,10 +187,10 @@ typedef struct { /** * When iterating over a diff, callback that will be made per file. */ -typedef int (*git_diff_file_fn)( - void *cb_data, +typedef int (*git_diff_file_cb)( const git_diff_delta *delta, - float progress); + float progress, + void *payload); /** * Structure describing a hunk of a diff. @@ -204,31 +205,31 @@ typedef struct { /** * When iterating over a diff, callback that will be made per hunk. */ -typedef int (*git_diff_hunk_fn)( - void *cb_data, +typedef int (*git_diff_hunk_cb)( const git_diff_delta *delta, const git_diff_range *range, const char *header, - size_t header_len); + size_t header_len, + void *payload); /** * Line origin constants. * * These values describe where a line came from and will be passed to - * the git_diff_data_fn when iterating over a diff. There are some + * the git_diff_data_cb when iterating over a diff. There are some * special origin constants at the end that are used for the text * output callbacks to demarcate lines that are actually part of * the file or hunk headers. */ typedef enum { - /* These values will be sent to `git_diff_data_fn` along with the line */ + /* These values will be sent to `git_diff_data_cb` along with the line */ GIT_DIFF_LINE_CONTEXT = ' ', GIT_DIFF_LINE_ADDITION = '+', GIT_DIFF_LINE_DELETION = '-', GIT_DIFF_LINE_ADD_EOFNL = '\n', /**< Removed line w/o LF & added one with */ GIT_DIFF_LINE_DEL_EOFNL = '\0', /**< LF was removed at end of file */ - /* The following values will only be sent to a `git_diff_data_fn` when + /* The following values will only be sent to a `git_diff_data_cb` when * the content of a diff is being formatted (eg. through * git_diff_print_patch() or git_diff_print_compact(), for instance). */ @@ -245,13 +246,13 @@ typedef enum { * of text. This uses some extra GIT_DIFF_LINE_... constants for output * of lines of file and hunk headers. */ -typedef int (*git_diff_data_fn)( - void *cb_data, +typedef int (*git_diff_data_cb)( const git_diff_delta *delta, const git_diff_range *range, char line_origin, /**< GIT_DIFF_LINE_... value from above */ const char *content, - size_t content_len); + size_t content_len, + void *payload); /** * The diff patch is used to store all the text diffs for a delta. @@ -283,6 +284,8 @@ typedef enum { * Control behavior of rename and copy detection */ typedef struct { + unsigned int version; + /** Combination of git_diff_find_t values (default FIND_RENAMES) */ unsigned int flags; @@ -461,7 +464,6 @@ GIT_EXTERN(int) git_diff_find_similar( * the iteration and cause this return `GIT_EUSER`. * * @param diff A git_diff_list generated by one of the above functions. - * @param cb_data Reference pointer that will be passed to your callbacks. * @param file_cb Callback function to make per file in the diff. * @param hunk_cb Optional callback to make per hunk of text diff. This * callback is called to describe a range of lines in the @@ -469,14 +471,15 @@ GIT_EXTERN(int) git_diff_find_similar( * @param line_cb Optional callback to make per line of diff text. This * same callback will be made for context lines, added, and * removed lines, and even for a deleted trailing newline. + * @param payload Reference pointer that will be passed to your callbacks. * @return 0 on success, GIT_EUSER on non-zero callback, or error code */ GIT_EXTERN(int) git_diff_foreach( git_diff_list *diff, - void *cb_data, - git_diff_file_fn file_cb, - git_diff_hunk_fn hunk_cb, - git_diff_data_fn line_cb); + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_data_cb line_cb, + void *payload); /** * Iterate over a diff generating text output like "git diff --name-status". @@ -485,14 +488,14 @@ GIT_EXTERN(int) git_diff_foreach( * iteration and cause this return `GIT_EUSER`. * * @param diff A git_diff_list generated by one of the above functions. - * @param cb_data Reference pointer that will be passed to your callback. * @param print_cb Callback to make per line of diff text. + * @param payload Reference pointer that will be passed to your callback. * @return 0 on success, GIT_EUSER on non-zero callback, or error code */ GIT_EXTERN(int) git_diff_print_compact( git_diff_list *diff, - void *cb_data, - git_diff_data_fn print_cb); + git_diff_data_cb print_cb, + void *payload); /** * Look up the single character abbreviation for a delta status code. @@ -517,7 +520,7 @@ GIT_EXTERN(char) git_diff_status_char(git_delta_t status); * iteration and cause this return `GIT_EUSER`. * * @param diff A git_diff_list generated by one of the above functions. - * @param cb_data Reference pointer that will be passed to your callbacks. + * @param payload Reference pointer that will be passed to your callbacks. * @param print_cb Callback function to output lines of the diff. This * same function will be called for file headers, hunk * headers, and diff lines. Fortunately, you can probably @@ -527,8 +530,8 @@ GIT_EXTERN(char) git_diff_status_char(git_delta_t status); */ GIT_EXTERN(int) git_diff_print_patch( git_diff_list *diff, - void *cb_data, - git_diff_data_fn print_cb); + git_diff_data_cb print_cb, + void *payload); /** * Query how many diff records are there in a diff list. @@ -572,15 +575,15 @@ GIT_EXTERN(size_t) git_diff_num_deltas_of_type( * It is okay to pass NULL for either of the output parameters; if you pass * NULL for the `git_diff_patch`, then the text diff will not be calculated. * - * @param patch Output parameter for the delta patch object - * @param delta Output parameter for the delta object + * @param patch_out Output parameter for the delta patch object + * @param delta_out Output parameter for the delta object * @param diff Diff list object * @param idx Index into diff list * @return 0 on success, other value < 0 on error */ GIT_EXTERN(int) git_diff_get_patch( - git_diff_patch **patch, - const git_diff_delta **delta, + git_diff_patch **patch_out, + const git_diff_delta **delta_out, git_diff_list *diff, size_t idx); @@ -672,15 +675,15 @@ GIT_EXTERN(int) git_diff_patch_get_line_in_hunk( * and cause this return `GIT_EUSER`. * * @param patch A git_diff_patch representing changes to one file - * @param cb_data Reference pointer that will be passed to your callbacks. * @param print_cb Callback function to output lines of the patch. Will be * called for file headers, hunk headers, and diff lines. + * @param payload Reference pointer that will be passed to your callbacks. * @return 0 on success, GIT_EUSER on non-zero callback, or error code */ GIT_EXTERN(int) git_diff_patch_print( git_diff_patch *patch, - void *cb_data, - git_diff_data_fn print_cb); + git_diff_data_cb print_cb, + void *payload); /** * Get the content of a patch as a single diff text. @@ -718,10 +721,10 @@ GIT_EXTERN(int) git_diff_blobs( git_blob *old_blob, git_blob *new_blob, const git_diff_options *options, - void *cb_data, - git_diff_file_fn file_cb, - git_diff_hunk_fn hunk_cb, - git_diff_data_fn line_cb); + git_diff_file_cb file_cb, + git_diff_hunk_cb hunk_cb, + git_diff_data_cb line_cb, + void *payload); GIT_END_DECL |