summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/diff.c8
-rw-r--r--examples/general.c2
-rw-r--r--include/git2/diff.h50
-rw-r--r--src/diff_output.c157
-rw-r--r--src/diff_output.h10
-rw-r--r--src/stash.c10
-rw-r--r--src/status.c12
-rw-r--r--tests-clar/diff/blob.c36
-rw-r--r--tests-clar/diff/diff_helpers.c39
-rw-r--r--tests-clar/diff/diff_helpers.h16
-rw-r--r--tests-clar/diff/index.c12
-rw-r--r--tests-clar/diff/patch.c8
-rw-r--r--tests-clar/diff/rename.c6
-rw-r--r--tests-clar/diff/tree.c10
-rw-r--r--tests-clar/diff/workdir.c70
15 files changed, 225 insertions, 221 deletions
diff --git a/examples/diff.c b/examples/diff.c
index c569b8664..a465182ba 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -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);
diff --git a/examples/general.c b/examples/general.c
index c4ff21d8b..d9bb6c04d 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -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
diff --git a/include/git2/diff.h b/include/git2/diff.h
index f925cbe39..fd00378af 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -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
diff --git a/src/diff_output.c b/src/diff_output.c
index 5c887cd7e..7873f066d 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -440,10 +440,10 @@ static void diff_context_init(
git_diff_list *diff,
git_repository *repo,
const git_diff_options *opts,
- void *data,
git_diff_file_cb file_cb,
git_diff_hunk_cb hunk_cb,
- git_diff_data_cb data_cb)
+ git_diff_data_cb data_cb,
+ void *payload)
{
memset(ctxt, 0, sizeof(diff_context));
@@ -453,8 +453,8 @@ static void diff_context_init(
ctxt->file_cb = file_cb;
ctxt->hunk_cb = hunk_cb;
ctxt->data_cb = data_cb;
- ctxt->cb_data = data;
- ctxt->cb_error = 0;
+ ctxt->payload = payload;
+ ctxt->error = 0;
setup_xdiff_options(ctxt->opts, &ctxt->xdiff_config, &ctxt->xdiff_params);
}
@@ -469,10 +469,10 @@ static int diff_delta_file_callback(
progress = ctxt->diff ? ((float)idx / ctxt->diff->deltas.length) : 1.0f;
- if (ctxt->file_cb(ctxt->cb_data, delta, progress) != 0)
- ctxt->cb_error = GIT_EUSER;
+ if (ctxt->file_cb(delta, progress, ctxt->payload) != 0)
+ ctxt->error = GIT_EUSER;
- return ctxt->cb_error;
+ return ctxt->error;
}
static void diff_patch_init(
@@ -643,14 +643,14 @@ static int diff_patch_cb(void *priv, mmbuffer_t *bufs, int len)
diff_context *ctxt = patch->ctxt;
if (len == 1) {
- ctxt->cb_error = parse_hunk_header(&ctxt->cb_range, bufs[0].ptr);
- if (ctxt->cb_error < 0)
- return ctxt->cb_error;
+ ctxt->error = parse_hunk_header(&ctxt->range, bufs[0].ptr);
+ if (ctxt->error < 0)
+ return ctxt->error;
if (ctxt->hunk_cb != NULL &&
- ctxt->hunk_cb(ctxt->cb_data, patch->delta, &ctxt->cb_range,
- bufs[0].ptr, bufs[0].size))
- ctxt->cb_error = GIT_EUSER;
+ ctxt->hunk_cb(patch->delta, &ctxt->range,
+ bufs[0].ptr, bufs[0].size, ctxt->payload))
+ ctxt->error = GIT_EUSER;
}
if (len == 2 || len == 3) {
@@ -661,12 +661,12 @@ static int diff_patch_cb(void *priv, mmbuffer_t *bufs, int len)
GIT_DIFF_LINE_CONTEXT;
if (ctxt->data_cb != NULL &&
- ctxt->data_cb(ctxt->cb_data, patch->delta, &ctxt->cb_range,
- origin, bufs[1].ptr, bufs[1].size))
- ctxt->cb_error = GIT_EUSER;
+ ctxt->data_cb(patch->delta, &ctxt->range,
+ origin, bufs[1].ptr, bufs[1].size, ctxt->payload))
+ ctxt->error = GIT_EUSER;
}
- if (len == 3 && !ctxt->cb_error) {
+ if (len == 3 && !ctxt->error) {
/* If we have a '+' and a third buf, then we have added a line
* without a newline and the old code had one, so DEL_EOFNL.
* If we have a '-' and a third buf, then we have removed a line
@@ -678,12 +678,12 @@ static int diff_patch_cb(void *priv, mmbuffer_t *bufs, int len)
GIT_DIFF_LINE_CONTEXT;
if (ctxt->data_cb != NULL &&
- ctxt->data_cb(ctxt->cb_data, patch->delta, &ctxt->cb_range,
- origin, bufs[2].ptr, bufs[2].size))
- ctxt->cb_error = GIT_EUSER;
+ ctxt->data_cb(patch->delta, &ctxt->range,
+ origin, bufs[2].ptr, bufs[2].size, ctxt->payload))
+ ctxt->error = GIT_EUSER;
}
- return ctxt->cb_error;
+ return ctxt->error;
}
static int diff_patch_generate(
@@ -720,7 +720,7 @@ static int diff_patch_generate(
xdl_diff(&old_xdiff_data, &new_xdiff_data,
&ctxt->xdiff_params, &ctxt->xdiff_config, &xdiff_callback);
- error = ctxt->cb_error;
+ error = ctxt->error;
if (!error)
patch->flags |= GIT_DIFF_PATCH_DIFFED;
@@ -775,13 +775,13 @@ static void diff_patch_free(git_diff_patch *patch)
#define MIN_LINE_STEP 8
static int diff_patch_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)
{
- git_diff_patch *patch = cb_data;
+ git_diff_patch *patch = payload;
diff_patch_hunk *hunk;
GIT_UNUSED(delta);
@@ -822,14 +822,14 @@ static int diff_patch_hunk_cb(
}
static int diff_patch_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)
{
- git_diff_patch *patch = cb_data;
+ git_diff_patch *patch = payload;
diff_patch_hunk *hunk;
diff_patch_line *last, *line;
@@ -904,10 +904,10 @@ static int diff_patch_line_cb(
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 data_cb)
+ git_diff_data_cb data_cb,
+ void *payload)
{
int error = 0;
diff_context ctxt;
@@ -916,7 +916,7 @@ int git_diff_foreach(
diff_context_init(
&ctxt, diff, diff->repo, &diff->opts,
- cb_data, file_cb, hunk_cb, data_cb);
+ file_cb, hunk_cb, data_cb, payload);
diff_patch_init(&ctxt, &patch);
@@ -952,7 +952,7 @@ int git_diff_foreach(
typedef struct {
git_diff_list *diff;
git_diff_data_cb print_cb;
- void *cb_data;
+ void *payload;
git_buf *buf;
} diff_print_info;
@@ -986,7 +986,7 @@ char git_diff_status_char(git_delta_t status)
}
static int print_compact(
- void *data, const git_diff_delta *delta, float progress)
+ const git_diff_delta *delta, float progress, void *data)
{
diff_print_info *pi = data;
char old_suffix, new_suffix, code = git_diff_status_char(delta->status);
@@ -1017,8 +1017,8 @@ static int print_compact(
if (git_buf_oom(pi->buf))
return -1;
- if (pi->print_cb(pi->cb_data, delta, NULL, GIT_DIFF_LINE_FILE_HDR,
- git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_FILE_HDR,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1029,8 +1029,8 @@ static int print_compact(
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)
{
int error;
git_buf buf = GIT_BUF_INIT;
@@ -1038,10 +1038,10 @@ int git_diff_print_compact(
pi.diff = diff;
pi.print_cb = print_cb;
- pi.cb_data = cb_data;
+ pi.payload = payload;
pi.buf = &buf;
- error = git_diff_foreach(diff, &pi, print_compact, NULL, NULL);
+ error = git_diff_foreach(diff, print_compact, NULL, NULL, &pi);
git_buf_free(&buf);
@@ -1079,7 +1079,7 @@ static int print_oid_range(diff_print_info *pi, const git_diff_delta *delta)
}
static int print_patch_file(
- void *data, const git_diff_delta *delta, float progress)
+ const git_diff_delta *delta, float progress, void *data)
{
diff_print_info *pi = data;
const char *oldpfx = pi->diff->opts.old_prefix;
@@ -1121,7 +1121,8 @@ static int print_patch_file(
if (git_buf_oom(pi->buf))
return -1;
- if (pi->print_cb(pi->cb_data, delta, NULL, GIT_DIFF_LINE_FILE_HDR, git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_FILE_HDR,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1137,8 +1138,8 @@ static int print_patch_file(
if (git_buf_oom(pi->buf))
return -1;
- if (pi->print_cb(pi->cb_data, delta, NULL, GIT_DIFF_LINE_BINARY,
- git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(delta, NULL, GIT_DIFF_LINE_BINARY,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1148,11 +1149,11 @@ static int print_patch_file(
}
static int print_patch_hunk(
- void *data,
const git_diff_delta *d,
const git_diff_range *r,
const char *header,
- size_t header_len)
+ size_t header_len,
+ void *data)
{
diff_print_info *pi = data;
@@ -1163,8 +1164,8 @@ static int print_patch_hunk(
if (git_buf_printf(pi->buf, "%.*s", (int)header_len, header) < 0)
return -1;
- if (pi->print_cb(pi->cb_data, d, r, GIT_DIFF_LINE_HUNK_HDR,
- git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(d, r, GIT_DIFF_LINE_HUNK_HDR,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1174,12 +1175,12 @@ static int print_patch_hunk(
}
static int print_patch_line(
- void *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 *data)
{
diff_print_info *pi = data;
@@ -1198,8 +1199,8 @@ static int print_patch_line(
if (git_buf_oom(pi->buf))
return -1;
- if (pi->print_cb(pi->cb_data, delta, range, line_origin,
- git_buf_cstr(pi->buf), git_buf_len(pi->buf)))
+ if (pi->print_cb(delta, range, line_origin,
+ git_buf_cstr(pi->buf), git_buf_len(pi->buf), pi->payload))
{
giterr_clear();
return GIT_EUSER;
@@ -1210,8 +1211,8 @@ static int print_patch_line(
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)
{
int error;
git_buf buf = GIT_BUF_INIT;
@@ -1219,11 +1220,11 @@ int git_diff_print_patch(
pi.diff = diff;
pi.print_cb = print_cb;
- pi.cb_data = cb_data;
+ pi.payload = payload;
pi.buf = &buf;
error = git_diff_foreach(
- diff, &pi, print_patch_file, print_patch_hunk, print_patch_line);
+ diff, print_patch_file, print_patch_hunk, print_patch_line, &pi);
git_buf_free(&buf);
@@ -1250,10 +1251,10 @@ 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 data_cb)
+ git_diff_data_cb data_cb,
+ void *payload)
{
int error;
git_repository *repo;
@@ -1276,7 +1277,7 @@ int git_diff_blobs(
diff_context_init(
&ctxt, NULL, repo, options,
- cb_data, file_cb, hunk_cb, data_cb);
+ file_cb, hunk_cb, data_cb, payload);
diff_patch_init(&ctxt, &patch);
@@ -1374,7 +1375,7 @@ int git_diff_get_patch(
diff_context_init(
&ctxt, diff, diff->repo, &diff->opts,
- NULL, NULL, diff_patch_hunk_cb, diff_patch_line_cb);
+ NULL, diff_patch_hunk_cb, diff_patch_line_cb, NULL);
if (git_diff_delta__should_skip(ctxt.opts, delta))
return 0;
@@ -1384,12 +1385,12 @@ int git_diff_get_patch(
return -1;
if (!(error = diff_patch_load(&ctxt, patch))) {
- ctxt.cb_data = patch;
+ ctxt.payload = patch;
error = diff_patch_generate(&ctxt, patch);
if (error == GIT_EUSER)
- error = ctxt.cb_error;
+ error = ctxt.error;
}
if (error)
@@ -1503,22 +1504,22 @@ notfound:
}
static int print_to_buffer_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)
{
- git_buf *output = cb_data;
+ git_buf *output = payload;
GIT_UNUSED(delta); GIT_UNUSED(range); GIT_UNUSED(line_origin);
return git_buf_put(output, content, content_len);
}
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)
{
int error;
git_buf temp = GIT_BUF_INIT;
@@ -1529,23 +1530,23 @@ int git_diff_patch_print(
pi.diff = patch->diff;
pi.print_cb = print_cb;
- pi.cb_data = cb_data;
+ pi.payload = payload;
pi.buf = &temp;
- error = print_patch_file(&pi, patch->delta, 0);
+ error = print_patch_file(patch->delta, 0, &pi);
for (h = 0; h < patch->hunks_size && !error; ++h) {
diff_patch_hunk *hunk = &patch->hunks[h];
- error = print_patch_hunk(&pi, patch->delta,
- &hunk->range, hunk->header, hunk->header_len);
+ error = print_patch_hunk(
+ patch->delta, &hunk->range, hunk->header, hunk->header_len, &pi);
for (l = 0; l < hunk->line_count && !error; ++l) {
diff_patch_line *line = &patch->lines[hunk->line_start + l];
error = print_patch_line(
- &pi, patch->delta, &hunk->range,
- line->origin, line->ptr, line->len);
+ patch->delta, &hunk->range,
+ line->origin, line->ptr, line->len, &pi);
}
}
@@ -1561,7 +1562,7 @@ int git_diff_patch_to_str(
int error;
git_buf output = GIT_BUF_INIT;
- error = git_diff_patch_print(patch, &output, print_to_buffer_cb);
+ error = git_diff_patch_print(patch, print_to_buffer_cb, &output);
/* GIT_EUSER means git_buf_put in print_to_buffer_cb returned -1,
* meaning a memory allocation failure, so just map to -1...
@@ -1577,8 +1578,8 @@ int git_diff_patch_to_str(
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)
{
int cmp;
git_diff_delta *i2h, *w2i;
@@ -1611,15 +1612,15 @@ int git_diff__paired_foreach(
STRCMP_CASESELECT(icase, i2h->old_file.path, w2i->old_file.path);
if (cmp < 0) {
- if (cb(cbref, i2h, NULL))
+ if (cb(i2h, NULL, payload))
return GIT_EUSER;
i++;
} else if (cmp > 0) {
- if (cb(cbref, NULL, w2i))
+ if (cb(NULL, w2i, payload))
return GIT_EUSER;
j++;
} else {
- if (cb(cbref, i2h, w2i))
+ if (cb(i2h, w2i, payload))
return GIT_EUSER;
i++; j++;
}
diff --git a/src/diff_output.h b/src/diff_output.h
index 8d7b5e472..13f2a120d 100644
--- a/src/diff_output.h
+++ b/src/diff_output.h
@@ -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
diff --git a/src/stash.c b/src/stash.c
index 89e5ff330..2efdd91c5 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -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)
diff --git a/src/status.c b/src/status.c
index b832cfe64..468417249 100644
--- a/src/status.c
+++ b/src/status.c
@@ -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(
diff --git a/tests-clar/diff/blob.c b/tests-clar/diff/blob.c
index cbef0f313..6a5645d4b 100644
--- a/tests-clar/diff/blob.c
+++ b/tests-clar/diff/blob.c
@@ -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);
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index 96a921350..1436ada03 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -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));
}
diff --git a/tests-clar/diff/diff_helpers.h b/tests-clar/diff/diff_helpers.h
index b5c36d64e..12591f63e 100644
--- a/tests-clar/diff/diff_helpers.h
+++ b/tests-clar/diff/diff_helpers.h
@@ -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);
diff --git a/tests-clar/diff/index.c b/tests-clar/diff/index.c
index e89260217..9591e3457 100644
--- a/tests-clar/diff/index.c
+++ b/tests-clar/diff/index.c
@@ -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);
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c
index 6aaf7651f..16ed2551b 100644
--- a/tests-clar/diff/patch.c
+++ b/tests-clar/diff/patch.c
@@ -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);
diff --git a/tests-clar/diff/rename.c b/tests-clar/diff/rename.c
index ee6a1816b..0d57f8ff0 100644
--- a/tests-clar/diff/rename.c
+++ b/tests-clar/diff/rename.c
@@ -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]);
diff --git a/tests-clar/diff/tree.c b/tests-clar/diff/tree.c
index 6eb5826e4..58dc4e6fa 100644
--- a/tests-clar/diff/tree.c
+++ b/tests-clar/diff/tree.c
@@ -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]);
diff --git a/tests-clar/diff/workdir.c b/tests-clar/diff/workdir.c
index 87013135d..7636c6e64 100644
--- a/tests-clar/diff/workdir.c
+++ b/tests-clar/diff/workdir.c
@@ -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