summaryrefslogtreecommitdiff
path: root/tests-clar/diff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-11-13 13:58:29 -0800
committerRussell Belfer <rb@github.com>2012-11-14 22:54:31 -0800
commit5735bf5e6ab4da347b601d4b85c09c5c701dc002 (patch)
treea6a33b5234bba3ba293af13c91e435213a4223c5 /tests-clar/diff
parent5a36f127808c7b470eef17b1a8a130dde0cc64a1 (diff)
downloadlibgit2-5735bf5e6ab4da347b601d4b85c09c5c701dc002.tar.gz
Fix diff API to better parameter order
The diff API is not in the parameter order one would expect from other libgit2 APIs. This fixes that.
Diffstat (limited to 'tests-clar/diff')
-rw-r--r--tests-clar/diff/diffiter.c18
-rw-r--r--tests-clar/diff/index.c6
-rw-r--r--tests-clar/diff/patch.c4
-rw-r--r--tests-clar/diff/rename.c4
-rw-r--r--tests-clar/diff/tree.c16
-rw-r--r--tests-clar/diff/workdir.c53
6 files changed, 52 insertions, 49 deletions
diff --git a/tests-clar/diff/diffiter.c b/tests-clar/diff/diffiter.c
index 86e8d1f57..f021d46f4 100644
--- a/tests-clar/diff/diffiter.c
+++ b/tests-clar/diff/diffiter.c
@@ -16,7 +16,7 @@ void test_diff_diffiter__create(void)
git_diff_list *diff;
size_t d, num_d;
- cl_git_pass(git_diff_workdir_to_index(repo, NULL, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
@@ -34,7 +34,7 @@ void test_diff_diffiter__iterate_files(void)
size_t d, num_d;
int count = 0;
- cl_git_pass(git_diff_workdir_to_index(repo, NULL, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL));
num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(6, (int)num_d);
@@ -57,7 +57,7 @@ void test_diff_diffiter__iterate_files_2(void)
size_t d, num_d;
int count = 0;
- cl_git_pass(git_diff_workdir_to_index(repo, NULL, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL));
num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(8, (int)num_d);
@@ -85,7 +85,7 @@ void test_diff_diffiter__iterate_files_and_hunks(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, &opts));
num_d = git_diff_num_deltas(diff);
@@ -138,7 +138,7 @@ void test_diff_diffiter__max_size_threshold(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, &opts));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
@@ -173,7 +173,7 @@ void test_diff_diffiter__max_size_threshold(void)
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
opts.max_size = 50; /* treat anything over 50 bytes as binary! */
- cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, &opts));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
@@ -216,7 +216,7 @@ void test_diff_diffiter__iterate_all(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, &opts));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
@@ -292,7 +292,7 @@ void test_diff_diffiter__iterate_randomly_while_saving_state(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, &opts));
num_d = git_diff_num_deltas(diff);
@@ -419,7 +419,7 @@ void test_diff_diffiter__iterate_and_generate_patch_text(void)
git_diff_list *diff;
size_t d, num_d;
- cl_git_pass(git_diff_workdir_to_index(repo, NULL, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL));
num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(8, (int)num_d);
diff --git a/tests-clar/diff/index.c b/tests-clar/diff/index.c
index eda8f066a..dede9419b 100644
--- a/tests-clar/diff/index.c
+++ b/tests-clar/diff/index.c
@@ -32,7 +32,7 @@ void test_diff_index__0(void)
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_index_to_tree(g_repo, &opts, a, &diff));
+ cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
@@ -60,7 +60,7 @@ void test_diff_index__0(void)
diff = NULL;
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_index_to_tree(g_repo, &opts, b, &diff));
+ cl_git_pass(git_diff_index_to_tree(&diff, g_repo, b, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
@@ -125,7 +125,7 @@ void test_diff_index__1(void)
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_index_to_tree(g_repo, &opts, a, &diff));
+ cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, &opts));
cl_assert_equal_i(
GIT_EUSER,
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c
index dce6d6da2..6aaf7651f 100644
--- a/tests-clar/diff/patch.c
+++ b/tests-clar/diff/patch.c
@@ -88,7 +88,7 @@ void test_diff_patch__can_properly_display_the_removal_of_a_file(void)
one = resolve_commit_oid_to_tree(g_repo, one_sha);
another = resolve_commit_oid_to_tree(g_repo, another_sha);
- cl_git_pass(git_diff_tree_to_tree(g_repo, NULL, one, another, &diff));
+ 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));
@@ -111,7 +111,7 @@ void test_diff_patch__to_string(void)
one = resolve_commit_oid_to_tree(g_repo, one_sha);
another = resolve_commit_oid_to_tree(g_repo, another_sha);
- cl_git_pass(git_diff_tree_to_tree(g_repo, NULL, one, another, &diff));
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, one, another, NULL));
cl_assert_equal_i(1, git_diff_num_deltas(diff));
diff --git a/tests-clar/diff/rename.c b/tests-clar/diff/rename.c
index 0ee1db842..1ea2e3fc9 100644
--- a/tests-clar/diff/rename.c
+++ b/tests-clar/diff/rename.c
@@ -47,7 +47,7 @@ void test_diff_rename__match_oid(void)
diffopts.flags |= GIT_DIFF_INCLUDE_UNMODIFIED;
cl_git_pass(git_diff_tree_to_tree(
- g_repo, &diffopts, old_tree, new_tree, &diff));
+ &diff, g_repo, old_tree, new_tree, &diffopts));
/* git diff --no-renames \
* 31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 \
@@ -79,7 +79,7 @@ void test_diff_rename__match_oid(void)
git_diff_list_free(diff);
cl_git_pass(git_diff_tree_to_tree(
- g_repo, &diffopts, old_tree, new_tree, &diff));
+ &diff, g_repo, old_tree, new_tree, &diffopts));
/* git diff --find-copies-harder \
* 31e47d8c1fa36d7f8d537b96158e3f024de0a9f2 \
diff --git a/tests-clar/diff/tree.c b/tests-clar/diff/tree.c
index f8b9a71a5..8e8939976 100644
--- a/tests-clar/diff/tree.c
+++ b/tests-clar/diff/tree.c
@@ -34,7 +34,7 @@ void test_diff_tree__0(void)
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff));
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
@@ -56,7 +56,7 @@ void test_diff_tree__0(void)
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, c, b, &diff));
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, b, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
@@ -141,9 +141,9 @@ void test_diff_tree__options(void)
opts = test_options[i];
if (test_ab_or_cd[i] == 0)
- cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff));
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
else
- cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, c, d, &diff));
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, d, &opts));
cl_git_pass(git_diff_foreach(
diff, &actual, diff_file_fn, diff_hunk_fn, diff_line_fn));
@@ -187,7 +187,7 @@ void test_diff_tree__bare(void)
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff));
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
cl_git_pass(git_diff_foreach(
diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
@@ -225,9 +225,9 @@ void test_diff_tree__merge(void)
cl_assert((b = resolve_commit_oid_to_tree(g_repo, b_commit)) != NULL);
cl_assert((c = resolve_commit_oid_to_tree(g_repo, c_commit)) != NULL);
- cl_git_pass(git_diff_tree_to_tree(g_repo, NULL, a, b, &diff1));
+ cl_git_pass(git_diff_tree_to_tree(&diff1, g_repo, a, b, NULL));
- cl_git_pass(git_diff_tree_to_tree(g_repo, NULL, c, b, &diff2));
+ cl_git_pass(git_diff_tree_to_tree(&diff2, g_repo, c, b, NULL));
git_tree_free(a);
git_tree_free(b);
@@ -279,7 +279,7 @@ void test_diff_tree__larger_hunks(void)
opts.context_lines = 1;
opts.interhunk_lines = 0;
- cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff));
+ cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
diff --git a/tests-clar/diff/workdir.c b/tests-clar/diff/workdir.c
index e617560f7..8de68e545 100644
--- a/tests-clar/diff/workdir.c
+++ b/tests-clar/diff/workdir.c
@@ -26,7 +26,7 @@ void test_diff_workdir__to_index(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -94,7 +94,7 @@ void test_diff_workdir__to_tree(void)
* The results are documented at the bottom of this file in the
* long comment entitled "PREPARATION OF TEST DATA".
*/
- cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, a, &diff));
+ cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -127,8 +127,8 @@ void test_diff_workdir__to_tree(void)
* a workdir to tree diff (even though it is not really). This is what
* you would get from "git diff --name-status 26a125ee1bf"
*/
- cl_git_pass(git_diff_index_to_tree(g_repo, &opts, a, &diff));
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff2));
+ cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, &opts));
+ cl_git_pass(git_diff_workdir_to_index(&diff2, g_repo, &opts));
cl_git_pass(git_diff_merge(diff, diff2));
git_diff_list_free(diff2);
@@ -164,8 +164,8 @@ void test_diff_workdir__to_tree(void)
/* Again, emulating "git diff <sha>" for testing purposes using
* "git diff --name-status 0017bd4ab1ec3" instead.
*/
- cl_git_pass(git_diff_index_to_tree(g_repo, &opts, b, &diff));
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff2));
+ cl_git_pass(git_diff_index_to_tree(&diff, g_repo, b, &opts));
+ cl_git_pass(git_diff_workdir_to_index(&diff2, g_repo, &opts));
cl_git_pass(git_diff_merge(diff, diff2));
git_diff_list_free(diff2);
@@ -216,7 +216,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1;
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -239,7 +239,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "modified_file";
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -262,7 +262,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "subdir";
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -285,7 +285,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "*_deleted";
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -324,7 +324,7 @@ void test_diff_workdir__filemode_changes(void)
/* test once with no mods */
- cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -347,7 +347,7 @@ void test_diff_workdir__filemode_changes(void)
cl_assert(cl_toggle_filemode("issue_592/a.txt"));
- cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -386,7 +386,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
/* test once with no mods */
- cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
@@ -402,7 +402,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
cl_assert(cl_toggle_filemode("issue_592/a.txt"));
- cl_git_pass(git_diff_workdir_to_index(g_repo, NULL, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
@@ -442,8 +442,8 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1;
- cl_git_pass(git_diff_index_to_tree(g_repo, &opts, tree, &diff_i2t));
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff_w2i));
+ cl_git_pass(git_diff_index_to_tree(&diff_i2t, g_repo, tree, &opts));
+ cl_git_pass(git_diff_workdir_to_index(&diff_w2i, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -529,7 +529,7 @@ void test_diff_workdir__eof_newline_changes(void)
opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1;
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -556,7 +556,7 @@ void test_diff_workdir__eof_newline_changes(void)
cl_git_append2file("status/current_file", "\n");
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -583,7 +583,7 @@ void test_diff_workdir__eof_newline_changes(void)
cl_git_rewritefile("status/current_file", "current_file");
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -699,13 +699,13 @@ void test_diff_workdir__larger_hunks(void)
/* okay, this is a bit silly, but oh well */
switch (i) {
case 0:
- cl_git_pass(git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, &opts));
break;
case 1:
- cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, a, &diff));
+ cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
break;
case 2:
- cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, b, &diff));
+ cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, b, &opts));
break;
}
@@ -784,7 +784,7 @@ void test_diff_workdir__submodules(void)
GIT_DIFF_RECURSE_UNTRACKED_DIRS |
GIT_DIFF_INCLUDE_UNTRACKED_CONTENT;
- cl_git_pass(git_diff_workdir_to_tree(g_repo, &opts, a, &diff));
+ cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
/* diff_print(stderr, diff); */
@@ -828,10 +828,13 @@ void test_diff_workdir__cannot_diff_against_a_bare_repository(void)
g_repo = cl_git_sandbox_init("testrepo.git");
- cl_assert_equal_i(GIT_EBAREREPO, git_diff_workdir_to_index(g_repo, &opts, &diff));
+ cl_assert_equal_i(
+ GIT_EBAREREPO, git_diff_workdir_to_index(&diff, g_repo, &opts));
cl_git_pass(git_repository_head_tree(&tree, g_repo));
- cl_assert_equal_i(GIT_EBAREREPO, git_diff_workdir_to_tree(g_repo, &opts, tree, &diff));
+
+ cl_assert_equal_i(
+ GIT_EBAREREPO, git_diff_workdir_to_tree(&diff, g_repo, tree, &opts));
git_tree_free(tree);
}