summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/attr/file.c25
-rw-r--r--tests-clar/attr/flags.c108
-rw-r--r--tests-clar/attr/lookup.c22
-rw-r--r--tests-clar/attr/repo.c39
-rw-r--r--tests-clar/diff/tree.c68
-rw-r--r--tests-clar/resources/attr_index/.gitted/HEAD1
-rw-r--r--tests-clar/resources/attr_index/.gitted/config6
-rw-r--r--tests-clar/resources/attr_index/.gitted/description1
-rw-r--r--tests-clar/resources/attr_index/.gitted/indexbin0 -> 520 bytes
-rw-r--r--tests-clar/resources/attr_index/.gitted/info/exclude6
-rw-r--r--tests-clar/resources/attr_index/.gitted/info/refs1
-rw-r--r--tests-clar/resources/attr_index/.gitted/logs/HEAD4
-rw-r--r--tests-clar/resources/attr_index/.gitted/logs/refs/heads/master4
-rw-r--r--tests-clar/resources/attr_index/.gitted/objects/38/12cfef36615db1788d4e63f90028007e17a3483
-rw-r--r--tests-clar/resources/attr_index/.gitted/objects/59/d942b8be2784bc96db9b22202c10815c9a077b1
-rw-r--r--tests-clar/resources/attr_index/.gitted/objects/cd/f17ea3fe625ef812f4dce7f423f4f299287505bin0 -> 61 bytes
-rw-r--r--tests-clar/resources/attr_index/.gitted/objects/f7/2502ddd01412bb20796ff812af56fd53b82b52bin0 -> 149 bytes
-rw-r--r--tests-clar/resources/attr_index/.gitted/objects/info/packs2
-rw-r--r--tests-clar/resources/attr_index/.gitted/objects/pack/pack-4e6438607204ce78827e3885594b2c0bb4f13895.idxbin0 -> 1492 bytes
-rw-r--r--tests-clar/resources/attr_index/.gitted/objects/pack/pack-4e6438607204ce78827e3885594b2c0bb4f13895.packbin0 -> 1106 bytes
-rw-r--r--tests-clar/resources/attr_index/.gitted/packed-refs2
-rw-r--r--tests-clar/resources/attr_index/.gitted/refs/heads/master1
-rw-r--r--tests-clar/resources/attr_index/README.md1
-rw-r--r--tests-clar/resources/attr_index/README.txt1
-rw-r--r--tests-clar/resources/attr_index/gitattributes4
-rw-r--r--tests-clar/resources/attr_index/sub/sub/.gitattributes3
-rw-r--r--tests-clar/resources/attr_index/sub/sub/README.md1
-rw-r--r--tests-clar/resources/attr_index/sub/sub/README.txt1
-rw-r--r--tests-clar/status/ignore.c4
29 files changed, 249 insertions, 60 deletions
diff --git a/tests-clar/attr/file.c b/tests-clar/attr/file.c
index 4e1010230..d19708838 100644
--- a/tests-clar/attr/file.c
+++ b/tests-clar/attr/file.c
@@ -11,9 +11,9 @@ void test_attr_file__simple_read(void)
git_attr_assignment *assign;
git_attr_rule *rule;
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr0"), file));
- cl_assert_equal_s(cl_fixture("attr/attr0"), file->path);
+ cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr0")));
+
+ cl_assert_equal_s(cl_fixture("attr/attr0"), file->key + 2);
cl_assert(file->rules.length == 1);
rule = get_rule(0);
@@ -37,9 +37,9 @@ void test_attr_file__match_variants(void)
git_attr_rule *rule;
git_attr_assignment *assign;
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr1"), file));
- cl_assert_equal_s(cl_fixture("attr/attr1"), file->path);
+ cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr1")));
+
+ cl_assert_equal_s(cl_fixture("attr/attr1"), file->key + 2);
cl_assert(file->rules.length == 10);
/* let's do a thorough check of this rule, then just verify
@@ -123,9 +123,9 @@ void test_attr_file__assign_variants(void)
git_attr_rule *rule;
git_attr_assignment *assign;
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr2"), file));
- cl_assert_equal_s(cl_fixture("attr/attr2"), file->path);
+ cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr2")));
+
+ cl_assert_equal_s(cl_fixture("attr/attr2"), file->key + 2);
cl_assert(file->rules.length == 11);
check_one_assign(file, 0, 0, "pat0", "simple", EXPECT_TRUE, NULL);
@@ -189,9 +189,8 @@ void test_attr_file__check_attr_examples(void)
git_attr_rule *rule;
git_attr_assignment *assign;
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr3"), file));
- cl_assert_equal_s(cl_fixture("attr/attr3"), file->path);
+ cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr3")));
+ cl_assert_equal_s(cl_fixture("attr/attr3"), file->key + 2);
cl_assert(file->rules.length == 3);
rule = get_rule(0);
@@ -214,7 +213,7 @@ void test_attr_file__check_attr_examples(void)
cl_assert(rule->assigns.length == 1);
assign = get_assign(rule, 0);
cl_assert_equal_s("myAttr", assign->name);
- cl_assert(assign->value == NULL);
+ cl_assert(GIT_ATTR_UNSPECIFIED(assign->value));
rule = get_rule(2);
cl_assert_equal_s("README", rule->match.pattern);
diff --git a/tests-clar/attr/flags.c b/tests-clar/attr/flags.c
new file mode 100644
index 000000000..5081de8b2
--- /dev/null
+++ b/tests-clar/attr/flags.c
@@ -0,0 +1,108 @@
+#include "clar_libgit2.h"
+#include "git2/attr.h"
+
+void test_attr_flags__cleanup(void)
+{
+ cl_git_sandbox_cleanup();
+}
+
+void test_attr_flags__bare(void)
+{
+ git_repository *repo = cl_git_sandbox_init("testrepo.git");
+ const char *value;
+
+ cl_assert(git_repository_is_bare(repo));
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM, "README.md", "diff", &value));
+ cl_assert(GIT_ATTR_UNSPECIFIED(value));
+}
+
+void test_attr_flags__index_vs_workdir(void)
+{
+ git_repository *repo = cl_git_sandbox_init("attr_index");
+ const char *value;
+
+ cl_assert(!git_repository_is_bare(repo));
+
+ /* wd then index */
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "README.md", "bar", &value));
+ cl_assert(GIT_ATTR_FALSE(value));
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "README.md", "blargh", &value));
+ cl_assert_equal_s(value, "goop");
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "README.txt", "foo", &value));
+ cl_assert(GIT_ATTR_FALSE(value));
+
+ /* index then wd */
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "README.md", "bar", &value));
+ cl_assert(GIT_ATTR_TRUE(value));
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "README.md", "blargh", &value));
+ cl_assert_equal_s(value, "garble");
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "README.txt", "foo", &value));
+ cl_assert(GIT_ATTR_TRUE(value));
+}
+
+void test_attr_flags__subdir(void)
+{
+ git_repository *repo = cl_git_sandbox_init("attr_index");
+ const char *value;
+
+ /* wd then index */
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "sub/sub/README.md", "bar", &value));
+ cl_assert_equal_s(value, "1234");
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "sub/sub/README.txt", "another", &value));
+ cl_assert_equal_s(value, "one");
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "sub/sub/README.txt", "again", &value));
+ cl_assert(GIT_ATTR_TRUE(value));
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_FILE_THEN_INDEX,
+ "sub/sub/README.txt", "beep", &value));
+ cl_assert_equal_s(value, "10");
+
+ /* index then wd */
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "sub/sub/README.md", "bar", &value));
+ cl_assert_equal_s(value, "1337");
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "sub/sub/README.txt", "another", &value));
+ cl_assert_equal_s(value, "one");
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "sub/sub/README.txt", "again", &value));
+ cl_assert(GIT_ATTR_TRUE(value));
+
+ cl_git_pass(git_attr_get(
+ repo, GIT_ATTR_CHECK_NO_SYSTEM | GIT_ATTR_CHECK_INDEX_THEN_FILE,
+ "sub/sub/README.txt", "beep", &value));
+ cl_assert_equal_s(value, "5");
+}
+
diff --git a/tests-clar/attr/lookup.c b/tests-clar/attr/lookup.c
index 81a4a55d3..b2a6aac64 100644
--- a/tests-clar/attr/lookup.c
+++ b/tests-clar/attr/lookup.c
@@ -9,9 +9,8 @@ void test_attr_lookup__simple(void)
git_attr_path path;
const char *value = NULL;
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr0"), file));
- cl_assert_equal_s(cl_fixture("attr/attr0"), file->path);
+ cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr0")));
+ cl_assert_equal_s(cl_fixture("attr/attr0"), file->key + 2);
cl_assert(file->rules.length == 1);
cl_git_pass(git_attr_path__init(&path, "test", NULL));
@@ -130,9 +129,8 @@ void test_attr_lookup__match_variants(void)
{ NULL, NULL, 0, NULL }
};
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr1"), file));
- cl_assert_equal_s(cl_fixture("attr/attr1"), file->path);
+ cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr1")));
+ cl_assert_equal_s(cl_fixture("attr/attr1"), file->key + 2);
cl_assert(file->rules.length == 10);
cl_git_pass(git_attr_path__init(&path, "/testing/for/pat0", NULL));
@@ -192,8 +190,7 @@ void test_attr_lookup__assign_variants(void)
{ NULL, NULL, 0, NULL }
};
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr2"), file));
+ cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr2")));
cl_assert(file->rules.length == 11);
run_test_cases(file, cases, 0);
@@ -228,8 +225,7 @@ void test_attr_lookup__check_attr_examples(void)
{ NULL, NULL, 0, NULL }
};
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr3"), file));
+ cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr3")));
cl_assert(file->rules.length == 3);
run_test_cases(file, cases, 0);
@@ -254,8 +250,10 @@ void test_attr_lookup__from_buffer(void)
{ NULL, NULL, 0, NULL }
};
- cl_git_pass(git_attr_file__new(&file, NULL));
- cl_git_pass(git_attr_file__from_buffer(NULL, "a* foo\nabc bar\n* baz", file));
+ cl_git_pass(git_attr_file__new(&file, 0, NULL, NULL));
+
+ cl_git_pass(git_attr_file__parse_buffer(NULL, "a* foo\nabc bar\n* baz", file));
+
cl_assert(file->rules.length == 3);
run_test_cases(file, cases, 0);
diff --git a/tests-clar/attr/repo.c b/tests-clar/attr/repo.c
index 7423c3045..006a49081 100644
--- a/tests-clar/attr/repo.c
+++ b/tests-clar/attr/repo.c
@@ -64,13 +64,13 @@ void test_attr_repo__get_one(void)
for (scan = test_cases; scan->path != NULL; scan++) {
const char *value;
- cl_git_pass(git_attr_get(g_repo, scan->path, scan->attr, &value));
+ cl_git_pass(git_attr_get(g_repo, 0, scan->path, scan->attr, &value));
attr_check_expected(scan->expected, scan->expected_str, value);
}
- cl_assert(git_attr_cache__is_cached(g_repo, ".git/info/attributes"));
- cl_assert(git_attr_cache__is_cached(g_repo, ".gitattributes"));
- cl_assert(git_attr_cache__is_cached(g_repo, "sub/.gitattributes"));
+ cl_assert(git_attr_cache__is_cached(g_repo, 0, ".git/info/attributes"));
+ cl_assert(git_attr_cache__is_cached(g_repo, 0, ".gitattributes"));
+ cl_assert(git_attr_cache__is_cached(g_repo, 0, "sub/.gitattributes"));
}
void test_attr_repo__get_many(void)
@@ -78,21 +78,21 @@ void test_attr_repo__get_many(void)
const char *names[4] = { "repoattr", "rootattr", "missingattr", "subattr" };
const char *values[4];
- cl_git_pass(git_attr_get_many(g_repo, "root_test1", 4, names, values));
+ cl_git_pass(git_attr_get_many(g_repo, 0, "root_test1", 4, names, values));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[2]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));
- cl_git_pass(git_attr_get_many(g_repo, "root_test2", 4, names, values));
+ cl_git_pass(git_attr_get_many(g_repo, 0, "root_test2", 4, names, values));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_FALSE(values[1]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[2]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));
- cl_git_pass(git_attr_get_many(g_repo, "sub/subdir_test1", 4, names, values));
+ cl_git_pass(git_attr_get_many(g_repo, 0, "sub/subdir_test1", 4, names, values));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
@@ -118,16 +118,17 @@ void test_attr_repo__foreach(void)
int count;
count = 0;
- cl_git_pass(git_attr_foreach(g_repo, "root_test1", &count_attrs, &count));
+ cl_git_pass(git_attr_foreach(
+ g_repo, 0, "root_test1", &count_attrs, &count));
cl_assert(count == 2);
count = 0;
- cl_git_pass(git_attr_foreach(g_repo, "sub/subdir_test1",
+ cl_git_pass(git_attr_foreach(g_repo, 0, "sub/subdir_test1",
&count_attrs, &count));
cl_assert(count == 4); /* repoattr, rootattr, subattr, negattr */
count = 0;
- cl_git_pass(git_attr_foreach(g_repo, "sub/subdir_test2.txt",
+ cl_git_pass(git_attr_foreach(g_repo, 0, "sub/subdir_test2.txt",
&count_attrs, &count));
cl_assert(count == 6); /* repoattr, rootattr, subattr, reposub, negattr, another */
}
@@ -136,19 +137,19 @@ void test_attr_repo__manpage_example(void)
{
const char *value;
- cl_git_pass(git_attr_get(g_repo, "sub/abc", "foo", &value));
+ cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "foo", &value));
cl_assert(GIT_ATTR_TRUE(value));
- cl_git_pass(git_attr_get(g_repo, "sub/abc", "bar", &value));
+ cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "bar", &value));
cl_assert(GIT_ATTR_UNSPECIFIED(value));
- cl_git_pass(git_attr_get(g_repo, "sub/abc", "baz", &value));
+ cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "baz", &value));
cl_assert(GIT_ATTR_FALSE(value));
- cl_git_pass(git_attr_get(g_repo, "sub/abc", "merge", &value));
+ cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "merge", &value));
cl_assert_equal_s("filfre", value);
- cl_git_pass(git_attr_get(g_repo, "sub/abc", "frotz", &value));
+ cl_git_pass(git_attr_get(g_repo, 0, "sub/abc", "frotz", &value));
cl_assert(GIT_ATTR_UNSPECIFIED(value));
}
@@ -159,7 +160,7 @@ void test_attr_repo__macros(void)
const char *names3[3] = { "macro2", "multi2", "multi3" };
const char *values[5];
- cl_git_pass(git_attr_get_many(g_repo, "binfile", 5, names, values));
+ cl_git_pass(git_attr_get_many(g_repo, 0, "binfile", 5, names, values));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
@@ -167,7 +168,7 @@ void test_attr_repo__macros(void)
cl_assert(GIT_ATTR_FALSE(values[3]));
cl_assert(GIT_ATTR_UNSPECIFIED(values[4]));
- cl_git_pass(git_attr_get_many(g_repo, "macro_test", 5, names2, values));
+ cl_git_pass(git_attr_get_many(g_repo, 0, "macro_test", 5, names2, values));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_TRUE(values[1]));
@@ -175,7 +176,7 @@ void test_attr_repo__macros(void)
cl_assert(GIT_ATTR_UNSPECIFIED(values[3]));
cl_assert_equal_s("77", values[4]);
- cl_git_pass(git_attr_get_many(g_repo, "macro_test", 3, names3, values));
+ cl_git_pass(git_attr_get_many(g_repo, 0, "macro_test", 3, names3, values));
cl_assert(GIT_ATTR_TRUE(values[0]));
cl_assert(GIT_ATTR_FALSE(values[1]));
@@ -188,7 +189,7 @@ void test_attr_repo__bad_macros(void)
"firstmacro", "secondmacro", "thirdmacro" };
const char *values[6];
- cl_git_pass(git_attr_get_many(g_repo, "macro_bad", 6, names, values));
+ cl_git_pass(git_attr_get_many(g_repo, 0, "macro_bad", 6, names, values));
/* these three just confirm that the "mymacro" rule ran */
cl_assert(GIT_ATTR_UNSPECIFIED(values[0]));
diff --git a/tests-clar/diff/tree.c b/tests-clar/diff/tree.c
index 1e269ae42..06f51a16b 100644
--- a/tests-clar/diff/tree.c
+++ b/tests-clar/diff/tree.c
@@ -5,7 +5,6 @@ static git_repository *g_repo = NULL;
void test_diff_tree__initialize(void)
{
- g_repo = cl_git_sandbox_init("attr");
}
void test_diff_tree__cleanup(void)
@@ -19,15 +18,16 @@ void test_diff_tree__0(void)
const char *a_commit = "605812a";
const char *b_commit = "370fe9ec22";
const char *c_commit = "f5b0af1fb4f5c";
- git_tree *a = resolve_commit_oid_to_tree(g_repo, a_commit);
- git_tree *b = resolve_commit_oid_to_tree(g_repo, b_commit);
- git_tree *c = resolve_commit_oid_to_tree(g_repo, c_commit);
+ git_tree *a, *b, *c;
git_diff_options opts = {0};
git_diff_list *diff = NULL;
diff_expects exp;
- cl_assert(a);
- cl_assert(b);
+ g_repo = cl_git_sandbox_init("attr");
+
+ cl_assert((a = resolve_commit_oid_to_tree(g_repo, a_commit)) != NULL);
+ 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);
opts.context_lines = 1;
opts.interhunk_lines = 1;
@@ -87,12 +87,7 @@ void test_diff_tree__options(void)
const char *b_commit = "605812ab7fe421fdd";
const char *c_commit = "f5b0af1fb4f5";
const char *d_commit = "a97cc019851";
-
- git_tree *a = resolve_commit_oid_to_tree(g_repo, a_commit);
- git_tree *b = resolve_commit_oid_to_tree(g_repo, b_commit);
- git_tree *c = resolve_commit_oid_to_tree(g_repo, c_commit);
- git_tree *d = resolve_commit_oid_to_tree(g_repo, d_commit);
-
+ git_tree *a, *b, *c, *d;
git_diff_options opts = {0};
git_diff_list *diff = NULL;
diff_expects actual;
@@ -133,8 +128,12 @@ void test_diff_tree__options(void)
diff_expects *expected;
int i;
- cl_assert(a);
- cl_assert(b);
+ g_repo = cl_git_sandbox_init("attr");
+
+ cl_assert((a = resolve_commit_oid_to_tree(g_repo, a_commit)) != NULL);
+ 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_assert((d = resolve_commit_oid_to_tree(g_repo, d_commit)) != NULL);
for (i = 0; test_expects[i].files > 0; i++) {
memset(&actual, 0, sizeof(actual)); /* clear accumulator */
@@ -168,3 +167,44 @@ void test_diff_tree__options(void)
git_tree_free(c);
git_tree_free(d);
}
+
+void test_diff_tree__bare(void)
+{
+ const char *a_commit = "8496071c1b46c85";
+ const char *b_commit = "be3563ae3f79";
+ git_tree *a, *b;
+ git_diff_options opts = {0};
+ git_diff_list *diff = NULL;
+ diff_expects exp;
+
+ g_repo = cl_git_sandbox_init("testrepo.git");
+
+ cl_assert((a = resolve_commit_oid_to_tree(g_repo, a_commit)) != NULL);
+ cl_assert((b = resolve_commit_oid_to_tree(g_repo, b_commit)) != NULL);
+
+ opts.context_lines = 1;
+ opts.interhunk_lines = 1;
+
+ memset(&exp, 0, sizeof(exp));
+
+ cl_git_pass(git_diff_tree_to_tree(g_repo, &opts, a, b, &diff));
+
+ cl_git_pass(git_diff_foreach(
+ diff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));
+
+ cl_assert(exp.files == 3);
+ cl_assert(exp.file_adds == 2);
+ cl_assert(exp.file_dels == 0);
+ cl_assert(exp.file_mods == 1);
+
+ cl_assert(exp.hunks == 3);
+
+ cl_assert(exp.lines == 4);
+ cl_assert(exp.line_ctxt == 0);
+ cl_assert(exp.line_adds == 3);
+ cl_assert(exp.line_dels == 1);
+
+ git_diff_list_free(diff);
+ git_tree_free(a);
+ git_tree_free(b);
+}
diff --git a/tests-clar/resources/attr_index/.gitted/HEAD b/tests-clar/resources/attr_index/.gitted/HEAD
new file mode 100644
index 000000000..cb089cd89
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests-clar/resources/attr_index/.gitted/config b/tests-clar/resources/attr_index/.gitted/config
new file mode 100644
index 000000000..af107929f
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/config
@@ -0,0 +1,6 @@
+[core]
+ repositoryformatversion = 0
+ filemode = true
+ bare = false
+ logallrefupdates = true
+ ignorecase = true
diff --git a/tests-clar/resources/attr_index/.gitted/description b/tests-clar/resources/attr_index/.gitted/description
new file mode 100644
index 000000000..498b267a8
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/description
@@ -0,0 +1 @@
+Unnamed repository; edit this file 'description' to name the repository.
diff --git a/tests-clar/resources/attr_index/.gitted/index b/tests-clar/resources/attr_index/.gitted/index
new file mode 100644
index 000000000..d87480332
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/index
Binary files differ
diff --git a/tests-clar/resources/attr_index/.gitted/info/exclude b/tests-clar/resources/attr_index/.gitted/info/exclude
new file mode 100644
index 000000000..a5196d1be
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/info/exclude
@@ -0,0 +1,6 @@
+# git ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
diff --git a/tests-clar/resources/attr_index/.gitted/info/refs b/tests-clar/resources/attr_index/.gitted/info/refs
new file mode 100644
index 000000000..60feca293
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/info/refs
@@ -0,0 +1 @@
+58f7cf825b553ef7c26e5b9f8a23599c1a9ca296 refs/heads/master
diff --git a/tests-clar/resources/attr_index/.gitted/logs/HEAD b/tests-clar/resources/attr_index/.gitted/logs/HEAD
new file mode 100644
index 000000000..ffd298c04
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/logs/HEAD
@@ -0,0 +1,4 @@
+0000000000000000000000000000000000000000 67c1640e91ccbaf0793591be09bf572cf40c9a53 Russell Belfer <rb@github.com> 1335817070 -0700 commit (initial): Initial commit
+67c1640e91ccbaf0793591be09bf572cf40c9a53 d441d7d88f52c28c2b23940ce4c33756748425f9 Russell Belfer <rb@github.com> 1335817296 -0700 commit: Adding some files in subtrees
+d441d7d88f52c28c2b23940ce4c33756748425f9 67c1640e91ccbaf0793591be09bf572cf40c9a53 Russell Belfer <rb@github.com> 1335817353 -0700 HEAD^: updating HEAD
+67c1640e91ccbaf0793591be09bf572cf40c9a53 58f7cf825b553ef7c26e5b9f8a23599c1a9ca296 Russell Belfer <rb@github.com> 1335817372 -0700 commit: Adding subtree data
diff --git a/tests-clar/resources/attr_index/.gitted/logs/refs/heads/master b/tests-clar/resources/attr_index/.gitted/logs/refs/heads/master
new file mode 100644
index 000000000..ffd298c04
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/logs/refs/heads/master
@@ -0,0 +1,4 @@
+0000000000000000000000000000000000000000 67c1640e91ccbaf0793591be09bf572cf40c9a53 Russell Belfer <rb@github.com> 1335817070 -0700 commit (initial): Initial commit
+67c1640e91ccbaf0793591be09bf572cf40c9a53 d441d7d88f52c28c2b23940ce4c33756748425f9 Russell Belfer <rb@github.com> 1335817296 -0700 commit: Adding some files in subtrees
+d441d7d88f52c28c2b23940ce4c33756748425f9 67c1640e91ccbaf0793591be09bf572cf40c9a53 Russell Belfer <rb@github.com> 1335817353 -0700 HEAD^: updating HEAD
+67c1640e91ccbaf0793591be09bf572cf40c9a53 58f7cf825b553ef7c26e5b9f8a23599c1a9ca296 Russell Belfer <rb@github.com> 1335817372 -0700 commit: Adding subtree data
diff --git a/tests-clar/resources/attr_index/.gitted/objects/38/12cfef36615db1788d4e63f90028007e17a348 b/tests-clar/resources/attr_index/.gitted/objects/38/12cfef36615db1788d4e63f90028007e17a348
new file mode 100644
index 000000000..ee2991571
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/objects/38/12cfef36615db1788d4e63f90028007e17a348
@@ -0,0 +1,3 @@
+x[
+ E*@PJ
+]&`w 'oMKDq45DF#!!=VZD.L:%L}!dCg*qв-LUkz~6閷W}}>g˾{f% G \ No newline at end of file
diff --git a/tests-clar/resources/attr_index/.gitted/objects/59/d942b8be2784bc96db9b22202c10815c9a077b b/tests-clar/resources/attr_index/.gitted/objects/59/d942b8be2784bc96db9b22202c10815c9a077b
new file mode 100644
index 000000000..ff33737db
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/objects/59/d942b8be2784bc96db9b22202c10815c9a077b
@@ -0,0 +1 @@
+x 0 @@kR@]<K4nY)l(ahFHcc^ \ No newline at end of file
diff --git a/tests-clar/resources/attr_index/.gitted/objects/cd/f17ea3fe625ef812f4dce7f423f4f299287505 b/tests-clar/resources/attr_index/.gitted/objects/cd/f17ea3fe625ef812f4dce7f423f4f299287505
new file mode 100644
index 000000000..2a410057e
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/objects/cd/f17ea3fe625ef812f4dce7f423f4f299287505
Binary files differ
diff --git a/tests-clar/resources/attr_index/.gitted/objects/f7/2502ddd01412bb20796ff812af56fd53b82b52 b/tests-clar/resources/attr_index/.gitted/objects/f7/2502ddd01412bb20796ff812af56fd53b82b52
new file mode 100644
index 000000000..048928000
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/objects/f7/2502ddd01412bb20796ff812af56fd53b82b52
Binary files differ
diff --git a/tests-clar/resources/attr_index/.gitted/objects/info/packs b/tests-clar/resources/attr_index/.gitted/objects/info/packs
new file mode 100644
index 000000000..559dc741c
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/objects/info/packs
@@ -0,0 +1,2 @@
+P pack-4e6438607204ce78827e3885594b2c0bb4f13895.pack
+
diff --git a/tests-clar/resources/attr_index/.gitted/objects/pack/pack-4e6438607204ce78827e3885594b2c0bb4f13895.idx b/tests-clar/resources/attr_index/.gitted/objects/pack/pack-4e6438607204ce78827e3885594b2c0bb4f13895.idx
new file mode 100644
index 000000000..fbef4aa1d
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/objects/pack/pack-4e6438607204ce78827e3885594b2c0bb4f13895.idx
Binary files differ
diff --git a/tests-clar/resources/attr_index/.gitted/objects/pack/pack-4e6438607204ce78827e3885594b2c0bb4f13895.pack b/tests-clar/resources/attr_index/.gitted/objects/pack/pack-4e6438607204ce78827e3885594b2c0bb4f13895.pack
new file mode 100644
index 000000000..09c9e06d9
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/objects/pack/pack-4e6438607204ce78827e3885594b2c0bb4f13895.pack
Binary files differ
diff --git a/tests-clar/resources/attr_index/.gitted/packed-refs b/tests-clar/resources/attr_index/.gitted/packed-refs
new file mode 100644
index 000000000..6b3e4decf
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/packed-refs
@@ -0,0 +1,2 @@
+# pack-refs with: peeled
+58f7cf825b553ef7c26e5b9f8a23599c1a9ca296 refs/heads/master
diff --git a/tests-clar/resources/attr_index/.gitted/refs/heads/master b/tests-clar/resources/attr_index/.gitted/refs/heads/master
new file mode 100644
index 000000000..9b7562931
--- /dev/null
+++ b/tests-clar/resources/attr_index/.gitted/refs/heads/master
@@ -0,0 +1 @@
+3812cfef36615db1788d4e63f90028007e17a348
diff --git a/tests-clar/resources/attr_index/README.md b/tests-clar/resources/attr_index/README.md
new file mode 100644
index 000000000..59d942b8b
--- /dev/null
+++ b/tests-clar/resources/attr_index/README.md
@@ -0,0 +1 @@
+This is contains tests for when the index and work dir differ
diff --git a/tests-clar/resources/attr_index/README.txt b/tests-clar/resources/attr_index/README.txt
new file mode 100644
index 000000000..874c12b79
--- /dev/null
+++ b/tests-clar/resources/attr_index/README.txt
@@ -0,0 +1 @@
+This contains files for testing when the index and the workdir differ
diff --git a/tests-clar/resources/attr_index/gitattributes b/tests-clar/resources/attr_index/gitattributes
new file mode 100644
index 000000000..cdf17ea3f
--- /dev/null
+++ b/tests-clar/resources/attr_index/gitattributes
@@ -0,0 +1,4 @@
+* bar
+*.txt -foo beep=10
+*.md blargh=goop -bar
+
diff --git a/tests-clar/resources/attr_index/sub/sub/.gitattributes b/tests-clar/resources/attr_index/sub/sub/.gitattributes
new file mode 100644
index 000000000..060c9a261
--- /dev/null
+++ b/tests-clar/resources/attr_index/sub/sub/.gitattributes
@@ -0,0 +1,3 @@
+*.txt another=one again
+*.md bar=1234
+
diff --git a/tests-clar/resources/attr_index/sub/sub/README.md b/tests-clar/resources/attr_index/sub/sub/README.md
new file mode 100644
index 000000000..59652e349
--- /dev/null
+++ b/tests-clar/resources/attr_index/sub/sub/README.md
@@ -0,0 +1 @@
+More testing
diff --git a/tests-clar/resources/attr_index/sub/sub/README.txt b/tests-clar/resources/attr_index/sub/sub/README.txt
new file mode 100644
index 000000000..59652e349
--- /dev/null
+++ b/tests-clar/resources/attr_index/sub/sub/README.txt
@@ -0,0 +1 @@
+More testing
diff --git a/tests-clar/status/ignore.c b/tests-clar/status/ignore.c
index 94f8c3de3..e92d6a577 100644
--- a/tests-clar/status/ignore.c
+++ b/tests-clar/status/ignore.c
@@ -47,8 +47,8 @@ void test_status_ignore__0(void)
}
/* confirm that ignore files were cached */
- cl_assert(git_attr_cache__is_cached(g_repo, ".git/info/exclude"));
- cl_assert(git_attr_cache__is_cached(g_repo, ".gitignore"));
+ cl_assert(git_attr_cache__is_cached(g_repo, 0, ".git/info/exclude"));
+ cl_assert(git_attr_cache__is_cached(g_repo, 0, ".gitignore"));
}