index: add tests around case switching We were missing tests for switching the case-sensitivity of an index in-memory and then looking up entries in it.
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
diff --git a/tests/index/filemodes.c b/tests/index/filemodes.c
index b390799..6442d77 100644
--- a/tests/index/filemodes.c
+++ b/tests/index/filemodes.c
@@ -239,6 +239,7 @@ void test_index_filemodes__invalid(void)
cl_git_pass(git_repository_index(&index, g_repo));
+ GIT_IDXENTRY_STAGE_SET(&entry, 0);
entry.path = "foo";
entry.mode = GIT_OBJ_BLOB;
cl_git_fail(git_index_add(index, &entry));
diff --git a/tests/index/tests.c b/tests/index/tests.c
index e1ff12a..f1a0578 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -792,10 +792,43 @@ void test_index_tests__reload_while_ignoring_case(void)
cl_git_pass(git_index_set_caps(index, caps &= ~GIT_INDEXCAP_IGNORE_CASE));
cl_git_pass(git_index_read(index, true));
cl_git_pass(git_vector_verify_sorted(&index->entries));
+ cl_assert(git_index_get_bypath(index, ".HEADER", 0));
+ cl_assert_equal_p(NULL, git_index_get_bypath(index, ".header", 0));
cl_git_pass(git_index_set_caps(index, caps | GIT_INDEXCAP_IGNORE_CASE));
cl_git_pass(git_index_read(index, true));
cl_git_pass(git_vector_verify_sorted(&index->entries));
+ cl_assert(git_index_get_bypath(index, ".HEADER", 0));
+ cl_assert(git_index_get_bypath(index, ".header", 0));
+
+ git_index_free(index);
+}
+
+void test_index_tests__change_icase_on_instance(void)
+{
+ git_index *index;
+ unsigned int caps;
+ const git_index_entry *e;
+
+ cl_git_pass(git_index_open(&index, TEST_INDEX_PATH));
+ cl_git_pass(git_vector_verify_sorted(&index->entries));
+
+ caps = git_index_caps(index);
+ cl_git_pass(git_index_set_caps(index, caps &= ~GIT_INDEXCAP_IGNORE_CASE));
+ cl_assert_equal_i(false, index->ignore_case);
+ cl_git_pass(git_vector_verify_sorted(&index->entries));
+ cl_assert(e = git_index_get_bypath(index, "src/common.h", 0));
+ cl_assert_equal_p(NULL, e = git_index_get_bypath(index, "SRC/Common.h", 0));
+ cl_assert(e = git_index_get_bypath(index, "COPYING", 0));
+ cl_assert_equal_p(NULL, e = git_index_get_bypath(index, "copying", 0));
+
+ cl_git_pass(git_index_set_caps(index, caps | GIT_INDEXCAP_IGNORE_CASE));
+ cl_assert_equal_i(true, index->ignore_case);
+ cl_git_pass(git_vector_verify_sorted(&index->entries));
+ cl_assert(e = git_index_get_bypath(index, "COPYING", 0));
+ cl_assert_equal_s("COPYING", e->path);
+ cl_assert(e = git_index_get_bypath(index, "copying", 0));
+ cl_assert_equal_s("COPYING", e->path);
git_index_free(index);
}