static void assert_proper_normalization(git_index *index, const char *filename, const char *expected_sha) { size_t index_pos; const git_index_entry *entry; add_to_workdir(filename, CONTENT); cl_git_pass(git_index_add_bypath(index, filename)); cl_assert(!git_index_find(&index_pos, index, filename)); entry = git_index_get_byindex(index, index_pos); cl_assert_equal_i(0, git_oid_streq(&entry->oid, expected_sha)); }
void test_attr_repo__staging_properly_normalizes_line_endings_according_to_gitattributes_directives(void) { git_index* index; cl_git_pass(git_repository_index(&index, g_repo)); add_to_workdir(".gitattributes", GITATTR); assert_proper_normalization(index, "text.txt", "22c74203bace3c2e950278c7ab08da0fca9f4e9b"); assert_proper_normalization(index, "huh.dunno", "22c74203bace3c2e950278c7ab08da0fca9f4e9b"); assert_proper_normalization(index, "binary.data", "66eeff1fcbacf589e6d70aa70edd3fce5be2b37c"); git_index_free(index); }
static void assert_proper_normalization(git_index *index, const char *filename, const char *expected_sha) { int index_pos; git_index_entry *entry; add_to_workdir(filename, CONTENT); cl_git_pass(git_index_add_from_workdir(index, filename)); index_pos = git_index_find(index, filename); cl_assert(index_pos >= 0); entry = git_index_get_byindex(index, index_pos); cl_assert_equal_i(0, git_oid_streq(&entry->oid, expected_sha)); }