Commit 793c4385 by Russell Belfer Committed by Ben Straub

Update diff callback param order

This makes the diff functions that take callbacks both take
the payload parameter after the callback function pointers and
pass the payload as the last argument to the callback function
instead of the first.  This should make them consistent with
other callbacks across the API.
parent 54b2a37a
......@@ -63,12 +63,12 @@ char *colors[] = {
};
static int printer(
void *data,
const git_diff_delta *delta,
const git_diff_range *range,
char usage,
const char *line,
size_t line_len)
size_t line_len,
void *data)
{
int *last_color = data, color = 0;
......@@ -225,9 +225,9 @@ int main(int argc, char *argv[])
fputs(colors[0], stdout);
if (compact)
check(git_diff_print_compact(diff, &color, printer), "Displaying diff");
check(git_diff_print_compact(diff, printer, &color), "Displaying diff");
else
check(git_diff_print_patch(diff, &color, printer), "Displaying diff");
check(git_diff_print_patch(diff, printer, &color), "Displaying diff");
if (color >= 0)
fputs(colors[0], stdout);
......
......@@ -298,7 +298,7 @@ int main (int argc, char** argv)
// Note that this buffer may not be contain ASCII data for certain blobs (e.g. binary files):
// do not consider the buffer a NULL-terminated string, and use the `git_blob_rawsize` attribute to
// find out its exact size in bytes
printf("Blob Size: %ld\n", git_blob_rawsize(blob)); // 8
printf("Blob Size: %ld\n", (long)git_blob_rawsize(blob)); // 8
git_blob_rawcontent(blob); // "content"
// ### Revwalking
......
......@@ -188,9 +188,9 @@ typedef struct {
* When iterating over a diff, callback that will be made per file.
*/
typedef int (*git_diff_file_cb)(
void *cb_data,
const git_diff_delta *delta,
float progress);
float progress,
void *payload);
/**
* Structure describing a hunk of a diff.
......@@ -206,11 +206,11 @@ typedef struct {
* When iterating over a diff, callback that will be made per hunk.
*/
typedef int (*git_diff_hunk_cb)(
void *cb_data,
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.
......@@ -247,12 +247,12 @@ typedef enum {
* of lines of file and hunk headers.
*/
typedef int (*git_diff_data_cb)(
void *cb_data,
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.
......@@ -284,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;
......@@ -462,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
......@@ -470,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_cb file_cb,
git_diff_hunk_cb hunk_cb,
git_diff_data_cb line_cb);
git_diff_data_cb line_cb,
void *payload);
/**
* Iterate over a diff generating text output like "git diff --name-status".
......@@ -486,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_cb print_cb);
git_diff_data_cb print_cb,
void *payload);
/**
* Look up the single character abbreviation for a delta status code.
......@@ -518,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
......@@ -528,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_cb print_cb);
git_diff_data_cb print_cb,
void *payload);
/**
* Query how many diff records are there in a diff list.
......@@ -573,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);
......@@ -673,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_cb print_cb);
git_diff_data_cb print_cb,
void *payload);
/**
* Get the content of a patch as a single diff text.
......@@ -719,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_cb file_cb,
git_diff_hunk_cb hunk_cb,
git_diff_data_cb line_cb);
git_diff_data_cb line_cb,
void *payload);
GIT_END_DECL
......
......@@ -30,9 +30,9 @@ typedef struct {
git_diff_file_cb file_cb;
git_diff_hunk_cb hunk_cb;
git_diff_data_cb data_cb;
void *cb_data;
int cb_error;
git_diff_range cb_range;
void *payload;
int error;
git_diff_range range;
xdemitconf_t xdiff_config;
xpparam_t xdiff_params;
} diff_context;
......@@ -86,7 +86,7 @@ typedef struct {
extern int git_diff__paired_foreach(
git_diff_list *idx2head,
git_diff_list *wd2idx,
int (*cb)(void *cbref, git_diff_delta *i2h, git_diff_delta *w2i),
void *cbref);
int (*cb)(git_diff_delta *i2h, git_diff_delta *w2i, void *payload),
void *payload);
#endif
......@@ -169,12 +169,12 @@ struct cb_data {
};
static int update_index_cb(
void *cb_data,
const git_diff_delta *delta,
float progress)
float progress,
void *payload)
{
int pos;
struct cb_data *data = (struct cb_data *)cb_data;
struct cb_data *data = (struct cb_data *)payload;
GIT_UNUSED(progress);
......@@ -253,7 +253,7 @@ static int build_untracked_tree(
if (git_diff_workdir_to_tree(&diff, git_index_owner(index), i_tree, &opts) < 0)
goto cleanup;
if (git_diff_foreach(diff, &data, update_index_cb, NULL, NULL) < 0)
if (git_diff_foreach(diff, update_index_cb, NULL, NULL, &data) < 0)
goto cleanup;
if (build_tree_from_index(tree_out, index) < 0)
......@@ -334,7 +334,7 @@ static int build_workdir_tree(
data.index = index;
data.include_changed = true;
if (git_diff_foreach(diff, &data, update_index_cb, NULL, NULL) < 0)
if (git_diff_foreach(diff, update_index_cb, NULL, NULL, &data) < 0)
goto cleanup;
if (build_tree_from_index(tree_out, index) < 0)
......
......@@ -79,13 +79,13 @@ static unsigned int workdir_delta2status(git_delta_t workdir_status)
typedef struct {
int (*cb)(const char *, unsigned int, void *);
void *cbdata;
void *payload;
} status_user_callback;
static int status_invoke_cb(
void *cbref, git_diff_delta *i2h, git_diff_delta *w2i)
git_diff_delta *i2h, git_diff_delta *w2i, void *payload)
{
status_user_callback *usercb = cbref;
status_user_callback *usercb = payload;
const char *path = NULL;
unsigned int status = 0;
......@@ -98,14 +98,14 @@ static int status_invoke_cb(
status |= index_delta2status(i2h->status);
}
return usercb->cb(path, status, usercb->cbdata);
return usercb->cb(path, status, usercb->payload);
}
int git_status_foreach_ext(
git_repository *repo,
const git_status_options *opts,
int (*cb)(const char *, unsigned int, void *),
void *cbdata)
void *payload)
{
int err = 0;
git_diff_options diffopt;
......@@ -152,7 +152,7 @@ int git_status_foreach_ext(
goto cleanup;
usercb.cb = cb;
usercb.cbdata = cbdata;
usercb.payload = payload;
if (show == GIT_STATUS_SHOW_INDEX_THEN_WORKDIR) {
if ((err = git_diff__paired_foreach(
......
......@@ -59,7 +59,7 @@ void test_diff_blob__can_compare_text_blobs(void)
/* diff on tests/resources/attr/root_test1 */
cl_git_pass(git_diff_blobs(
a, b, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
a, b, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.file_status[GIT_DELTA_MODIFIED]);
......@@ -74,7 +74,7 @@ void test_diff_blob__can_compare_text_blobs(void)
/* diff on tests/resources/attr/root_test2 */
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
b, c, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
b, c, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.file_status[GIT_DELTA_MODIFIED]);
......@@ -89,7 +89,7 @@ void test_diff_blob__can_compare_text_blobs(void)
/* diff on tests/resources/attr/root_test3 */
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
a, c, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
a, c, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.file_status[GIT_DELTA_MODIFIED]);
......@@ -103,7 +103,7 @@ void test_diff_blob__can_compare_text_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
c, d, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
c, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.file_status[GIT_DELTA_MODIFIED]);
......@@ -125,7 +125,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
git_blob *e = NULL;
cl_git_pass(git_diff_blobs(
d, e, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
d, e, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.file_status[GIT_DELTA_DELETED]);
......@@ -140,7 +140,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
d, e, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
d, e, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.file_status[GIT_DELTA_ADDED]);
......@@ -155,7 +155,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
alien, NULL, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
alien, NULL, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.files_binary);
......@@ -166,7 +166,7 @@ void test_diff_blob__can_compare_against_null_blobs(void)
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
NULL, alien, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
NULL, alien, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.files);
cl_assert_equal_i(1, expected.files_binary);
......@@ -186,21 +186,21 @@ static void assert_identical_blobs_comparison(diff_expects *expected)
void test_diff_blob__can_compare_identical_blobs(void)
{
cl_git_pass(git_diff_blobs(
d, d, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
d, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(0, expected.files_binary);
assert_identical_blobs_comparison(&expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
NULL, NULL, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
NULL, NULL, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(0, expected.files_binary);
assert_identical_blobs_comparison(&expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
alien, alien, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
alien, alien, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert(expected.files_binary > 0);
assert_identical_blobs_comparison(&expected);
......@@ -226,14 +226,14 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
cl_git_pass(git_blob_lookup_prefix(&heart, g_repo, &h_oid, 4));
cl_git_pass(git_diff_blobs(
alien, heart, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
alien, heart, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
heart, alien, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
heart, alien, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
......@@ -243,14 +243,14 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
void test_diff_blob__can_compare_a_binary_blob_and_a_text_blob(void)
{
cl_git_pass(git_diff_blobs(
alien, d, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
alien, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
d, alien, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
d, alien, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
assert_binary_blobs_comparison(&expected);
}
......@@ -291,7 +291,7 @@ void test_diff_blob__comparing_two_text_blobs_honors_interhunkcontext(void)
/* Test with default inter-hunk-context (not set) => default is 0 */
cl_git_pass(git_diff_blobs(
old_d, d, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
old_d, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(2, expected.hunks);
......@@ -299,7 +299,7 @@ void test_diff_blob__comparing_two_text_blobs_honors_interhunkcontext(void)
opts.interhunk_lines = 0;
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
old_d, d, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
old_d, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(2, expected.hunks);
......@@ -307,7 +307,7 @@ void test_diff_blob__comparing_two_text_blobs_honors_interhunkcontext(void)
opts.interhunk_lines = 1;
memset(&expected, 0, sizeof(expected));
cl_git_pass(git_diff_blobs(
old_d, d, &opts, &expected, diff_file_cb, diff_hunk_cb, diff_line_cb));
old_d, d, &opts, diff_file_cb, diff_hunk_cb, diff_line_cb, &expected));
cl_assert_equal_i(1, expected.hunks);
......
......@@ -22,11 +22,11 @@ git_tree *resolve_commit_oid_to_tree(
}
int diff_file_cb(
void *cb_data,
const git_diff_delta *delta,
float progress)
float progress,
void *payload)
{
diff_expects *e = cb_data;
diff_expects *e = payload;
GIT_UNUSED(progress);
......@@ -43,13 +43,13 @@ int diff_file_cb(
}
int diff_hunk_cb(
void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
const char *header,
size_t header_len)
size_t header_len,
void *payload)
{
diff_expects *e = cb_data;
diff_expects *e = payload;
GIT_UNUSED(delta);
GIT_UNUSED(header);
......@@ -62,14 +62,14 @@ int diff_hunk_cb(
}
int diff_line_cb(
void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin,
const char *content,
size_t content_len)
size_t content_len,
void *payload)
{
diff_expects *e = cb_data;
diff_expects *e = payload;
GIT_UNUSED(delta);
GIT_UNUSED(range);
......@@ -103,10 +103,10 @@ int diff_line_cb(
int diff_foreach_via_iterator(
git_diff_list *diff,
void *data,
git_diff_file_cb file_cb,
git_diff_hunk_cb hunk_cb,
git_diff_data_cb line_cb)
git_diff_data_cb line_cb,
void *data)
{
size_t d, num_d = git_diff_num_deltas(diff);
......@@ -119,7 +119,7 @@ int diff_foreach_via_iterator(
cl_assert(delta);
/* call file_cb for this file */
if (file_cb != NULL && file_cb(data, delta, (float)d / num_d) != 0) {
if (file_cb != NULL && file_cb(delta, (float)d / num_d, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
......@@ -145,7 +145,7 @@ int diff_foreach_via_iterator(
cl_git_pass(git_diff_patch_get_hunk(
&range, &hdr, &hdr_len, &num_l, patch, h));
if (hunk_cb && hunk_cb(data, delta, range, hdr, hdr_len) != 0) {
if (hunk_cb && hunk_cb(delta, range, hdr, hdr_len, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
......@@ -160,7 +160,8 @@ int diff_foreach_via_iterator(
&origin, &line, &line_len, &old_lineno, &new_lineno,
patch, h, l));
if (line_cb(data, delta, range, origin, line, line_len) != 0) {
if (line_cb &&
line_cb(delta, range, origin, line, line_len, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
......@@ -178,23 +179,23 @@ abort:
}
static int diff_print_cb(
void *cb_data,
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)
{
GIT_UNUSED(cb_data);
GIT_UNUSED(payload);
GIT_UNUSED(delta);
GIT_UNUSED(range);
GIT_UNUSED(line_origin);
GIT_UNUSED(content_len);
fputs(content, (FILE *)cb_data);
fputs(content, (FILE *)payload);
return 0;
}
void diff_print(FILE *fp, git_diff_list *diff)
{
cl_git_pass(git_diff_print_patch(diff, fp ? fp : stderr, diff_print_cb));
cl_git_pass(git_diff_print_patch(diff, diff_print_cb, fp ? fp : stderr));
}
......@@ -21,30 +21,30 @@ typedef struct {
} diff_expects;
extern int diff_file_cb(
void *cb_data,
const git_diff_delta *delta,
float progress);
float progress,
void *cb_data);
extern int diff_hunk_cb(
void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
const char *header,
size_t header_len);
size_t header_len,
void *cb_data);
extern int diff_line_cb(
void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin,
const char *content,
size_t content_len);
size_t content_len,
void *cb_data);
extern int diff_foreach_via_iterator(
git_diff_list *diff,
void *data,
git_diff_file_cb file_cb,
git_diff_hunk_cb hunk_cb,
git_diff_data_cb line_cb);
git_diff_data_cb line_cb,
void *data);
extern void diff_print(FILE *fp, git_diff_list *diff);
......@@ -35,7 +35,7 @@ void test_diff_index__0(void)
cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
/* to generate these values:
* - cd to tests/resources/status,
......@@ -63,7 +63,7 @@ void test_diff_index__0(void)
cl_git_pass(git_diff_index_to_tree(&diff, g_repo, b, NULL, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
/* to generate these values:
* - cd to tests/resources/status,
......@@ -92,11 +92,11 @@ void test_diff_index__0(void)
}
static int diff_stop_after_2_files(
void *cb_data,
const git_diff_delta *delta,
float progress)
float progress,
void *payload)
{
diff_expects *e = cb_data;
diff_expects *e = payload;
GIT_UNUSED(progress);
GIT_UNUSED(delta);
......@@ -129,7 +129,7 @@ void test_diff_index__1(void)
cl_assert_equal_i(
GIT_EUSER,
git_diff_foreach(diff, &exp, diff_stop_after_2_files, NULL, NULL)
git_diff_foreach(diff, diff_stop_after_2_files, NULL, NULL, &exp)
);
cl_assert_equal_i(2, exp.files);
......
......@@ -22,14 +22,14 @@ void test_diff_patch__cleanup(void)
#define EXPECTED_HUNK "@@ -1,2 +0,0 @@\n"
static int check_removal_cb(
void *cb_data,
const git_diff_delta *delta,
const git_diff_range *range,
char line_origin,
const char *formatted_output,
size_t output_len)
size_t output_len,
void *payload)
{
GIT_UNUSED(cb_data);
GIT_UNUSED(payload);
GIT_UNUSED(output_len);
switch (line_origin) {
......@@ -90,7 +90,7 @@ void test_diff_patch__can_properly_display_the_removal_of_a_file(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, one, another, NULL));
cl_git_pass(git_diff_print_patch(diff, NULL, check_removal_cb));
cl_git_pass(git_diff_print_patch(diff, check_removal_cb, NULL));
git_diff_list_free(diff);
......
......@@ -55,7 +55,7 @@ void test_diff_rename__match_oid(void)
*/
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(4, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
......@@ -69,7 +69,7 @@ void test_diff_rename__match_oid(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
......@@ -91,7 +91,7 @@ void test_diff_rename__match_oid(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNMODIFIED]);
......
......@@ -37,7 +37,7 @@ void test_diff_tree__0(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(5, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
......@@ -59,7 +59,7 @@ void test_diff_tree__0(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, b, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -148,7 +148,7 @@ void test_diff_tree__options(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, d, &opts));
cl_git_pass(git_diff_foreach(
diff, &actual, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &actual));
expected = &test_expects[i];
cl_assert_equal_i(actual.files, expected->files);
......@@ -192,7 +192,7 @@ void test_diff_tree__bare(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
......@@ -242,7 +242,7 @@ void test_diff_tree__merge(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
diff1, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff1, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(6, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
......
......@@ -33,10 +33,10 @@ void test_diff_workdir__to_index(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
/* to generate these values:
* - cd to tests/resources/status,
......@@ -101,10 +101,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(14, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -137,10 +137,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(15, exp.files);
cl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);
......@@ -174,10 +174,10 @@ void test_diff_workdir__to_tree(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(16, exp.files);
cl_assert_equal_i(5, exp.file_status[GIT_DELTA_ADDED]);
......@@ -223,9 +223,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, NULL, NULL));
diff, diff_file_cb, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, &exp, diff_file_cb, NULL, NULL));
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
cl_assert_equal_i(13, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -246,9 +246,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, NULL, NULL));
diff, diff_file_cb, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, &exp, diff_file_cb, NULL, NULL));
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -269,9 +269,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, NULL, NULL));
diff, diff_file_cb, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, &exp, diff_file_cb, NULL, NULL));
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
cl_assert_equal_i(3, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -292,9 +292,9 @@ void test_diff_workdir__to_index_with_pathspec(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, NULL, NULL));
diff, diff_file_cb, NULL, NULL, &exp));
else
cl_git_pass(git_diff_foreach(diff, &exp, diff_file_cb, NULL, NULL));
cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, &exp));
cl_assert_equal_i(2, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -331,10 +331,10 @@ void test_diff_workdir__filemode_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
......@@ -354,10 +354,10 @@ void test_diff_workdir__filemode_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
......@@ -390,7 +390,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
......@@ -406,7 +406,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_MODIFIED]);
......@@ -450,10 +450,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff_i2t, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff_i2t, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -471,10 +471,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff_w2i, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff_w2i, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff_w2i, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff_w2i, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -494,10 +494,10 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff_i2t, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff_i2t, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff_i2t, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -536,10 +536,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(0, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -563,10 +563,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -590,10 +590,10 @@ void test_diff_workdir__eof_newline_changes(void)
if (use_iterator)
cl_git_pass(diff_foreach_via_iterator(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
else
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
cl_assert_equal_i(1, exp.files);
cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
......@@ -792,7 +792,7 @@ void test_diff_workdir__submodules(void)
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_cb, diff_hunk_cb, diff_line_cb));
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
/* the following differs from "git diff 873585" by one "untracked" file
* because the diff list includes the "not_submodule/" directory which
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment