add diff-index tests
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/tests-clay/object/tree/diff.c b/tests-clay/object/tree/diff.c
index d2d5f75..b2c7f69 100644
--- a/tests-clay/object/tree/diff.c
+++ b/tests-clay/object/tree/diff.c
@@ -3,6 +3,7 @@
#include "repository.h"
static git_repository *repo;
+static git_index *theindex;
static git_tree *atree, *btree;
static git_oid aoid, boid;
@@ -26,9 +27,18 @@ static int diff_cb(const git_tree_diff_data *diff, void *data)
return GIT_SUCCESS;
}
+static void test_diff(git_tree *a, git_tree *b, git_tree_diff_cb cb, void *data)
+{
+ cl_must_pass(git_tree_diff(a, b, cb, data));
+
+ cl_git_pass(git_index_read_tree(theindex, b));
+ cl_git_pass(git_tree_diff_index_recursive(a, theindex, cb, data));
+}
+
void test_object_tree_diff__initialize(void)
{
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+ cl_git_pass(git_repository_index(&theindex, repo));
}
void test_object_tree_diff__cleanup(void)
@@ -57,7 +67,7 @@ void test_object_tree_diff__addition(void)
cl_must_pass(git_tree_lookup(&atree, repo, &aoid));
cl_must_pass(git_tree_lookup(&btree, repo, &boid));
- cl_must_pass(git_tree_diff(atree, btree, diff_cb, &expect));
+ test_diff(atree, btree, diff_cb, &expect);
}
void test_object_tree_diff__deletion(void)
@@ -78,7 +88,7 @@ void test_object_tree_diff__deletion(void)
cl_must_pass(git_tree_lookup(&atree, repo, &aoid));
cl_must_pass(git_tree_lookup(&btree, repo, &boid));
- cl_must_pass(git_tree_diff(atree, btree, diff_cb, &expect));
+ test_diff(atree, btree, diff_cb, &expect);
}
void test_object_tree_diff__modification(void)
@@ -100,7 +110,7 @@ void test_object_tree_diff__modification(void)
cl_must_pass(git_tree_lookup(&atree, repo, &aoid));
cl_must_pass(git_tree_lookup(&btree, repo, &boid));
- cl_must_pass(git_tree_diff(atree, btree, diff_cb, &expect));
+ test_diff(atree, btree, diff_cb, &expect);
}
struct diff_more_data {
@@ -153,5 +163,5 @@ void test_object_tree_diff__more(void)
cl_must_pass(git_tree_lookup(&atree, repo, &aoid));
cl_must_pass(git_tree_lookup(&btree, repo, &boid));
- cl_must_pass(git_tree_diff(atree, btree, diff_more_cb, &more_data));
+ test_diff(atree, btree, diff_more_cb, &more_data);
}