void test_checkout_crlf__autocrlf_input_text_auto_attr(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; opts.checkout_strategy = GIT_CHECKOUT_FORCE; cl_git_mkfile("./crlf/.gitattributes", "* text=auto\n"); cl_repo_set_string(g_repo, "core.autocrlf", "input"); git_checkout_head(g_repo, &opts); check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW); check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW); }
void test_stash_apply__uses_reflog_like_indices_2(void) { git_oid oid; cl_git_mkfile("stash/untracked", "untracked\n"); cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); assert_status(repo, "untracked", GIT_ENOTFOUND); // stash@{0} is the newest stash we made immediately above cl_git_pass(git_stash_apply(repo, 0, NULL)); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "untracked", GIT_STATUS_WT_NEW); }
void test_stash_save__skip_submodules(void) { git_repository *untracked_repo; cl_git_pass(git_repository_init(&untracked_repo, "stash/untracked_repo", false)); cl_git_mkfile("stash/untracked_repo/content", "stuff"); git_repository_free(untracked_repo); assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW); cl_git_pass(git_stash_save( &stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW); }
void test_config_read__lone_variable_with_trailing_whitespace(void) { git_config *cfg; int b; cl_set_cleanup(&clean_test_config, NULL); cl_git_mkfile("./testconfig", "[foo]\n lonevariable \n"); cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig")); cl_git_pass(git_config_get_bool(&b, cfg, "foo.lonevariable")); cl_assert_equal_b(true, b); git_config_free(cfg); }
void test_stash_apply__conflict_untracked_with_default(void) { git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT; cl_git_mkfile("stash/when", "nothing\n"); cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT); cl_assert_equal_i(git_index_has_conflicts(repo_index), 0); assert_status(repo, "what", GIT_STATUS_CURRENT); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_CURRENT); assert_status(repo, "when", GIT_STATUS_WT_NEW); }
void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension(void) { git_strarray ref_list; /* Create a fake locked reference */ cl_git_mkfile( "./testrepo/.git/refs/heads/hanwen.lock", "144344043ba4d4a405da03de3844aa829ae8be0e\n"); cl_git_pass(git_reference_list(&ref_list, g_repo)); cl_assert_equal_i((int)ref_list.count, 15); git_strarray_free(&ref_list); }
static void make_test_data(const char *reponame, const char **files) { const char **scan; size_t repolen = strlen(reponame) + 1; g_repo = cl_git_sandbox_init(reponame); for (scan = files; *scan != NULL; ++scan) { cl_git_pass(git_futils_mkdir( *scan + repolen, reponame, 0777, GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST)); cl_git_mkfile(*scan, "contents"); } }
void test_checkout_index__options_open_flags(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; cl_git_mkfile("./testrepo/new.txt", "hi\n"); opts.checkout_strategy = GIT_CHECKOUT_FORCE | GIT_CHECKOUT_DONT_REMOVE_EXISTING; opts.file_open_flags = O_CREAT | O_RDWR | O_APPEND; cl_git_pass(git_checkout_index(g_repo, NULL, &opts)); check_file_contents("./testrepo/new.txt", "hi\nmy new file\n"); }
void test_apply_both__honors_crlf_attributes(void) { git_diff *diff; git_oid oid; git_commit *commit; const char *diff_file = DIFF_MODIFY_TWO_FILES; struct merge_index_entry index_expected[] = { { 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" }, { 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" }, { 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" }, { 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" }, { 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" }, { 0100644, "a7b066537e6be7109abfe4ff97b675d4e077da20", 0, "veal.txt" }, }; size_t index_expected_cnt = sizeof(index_expected) / sizeof(struct merge_index_entry); struct merge_index_entry workdir_expected[] = { { 0100644, "176a458f94e0ea5272ce67c36bf30b6be9caf623", 0, ".gitattributes" }, { 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" }, { 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" }, { 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" }, { 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" }, { 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" }, { 0100644, "a7b066537e6be7109abfe4ff97b675d4e077da20", 0, "veal.txt" }, }; size_t workdir_expected_cnt = sizeof(workdir_expected) / sizeof(struct merge_index_entry); cl_git_mkfile("merge-recursive/.gitattributes", "* text=auto\n"); cl_git_rmfile("merge-recursive/asparagus.txt"); cl_git_rmfile("merge-recursive/veal.txt"); git_oid_fromstr(&oid, "539bd011c4822c560c1d17cab095006b7a10f707"); cl_git_pass(git_commit_lookup(&commit, repo, &oid)); cl_git_pass(git_reset(repo, (git_object *)commit, GIT_RESET_HARD, NULL)); git_commit_free(commit); cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file))); cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL)); validate_apply_index(repo, index_expected, index_expected_cnt); validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt); git_diff_free(diff); }
void test_checkout_index__honor_the_gitattributes_directives(void) { const char *attributes = "branch_file.txt text eol=crlf\n" "new.txt text eol=lf\n"; cl_git_mkfile("./testrepo/.gitattributes", attributes); set_core_autocrlf_to(false); cl_git_pass(git_checkout_index(g_repo, &g_opts)); test_file_contents("./testrepo/README", "hey there\n"); test_file_contents("./testrepo/new.txt", "my new file\n"); test_file_contents("./testrepo/branch_file.txt", "hi\r\nbye!\r\n"); }
void test_reset_soft__fails_when_merging(void) { git_buf merge_head_path = GIT_BUF_INIT; cl_git_pass(git_repository_detach_head(repo)); cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD")); cl_git_mkfile(git_buf_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n"); retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO); cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT)); cl_git_pass(p_unlink(git_buf_cstr(&merge_head_path))); git_buf_free(&merge_head_path); }
static void build_workdir_tree(const char *root, int dirs, int subs) { int i, j; char buf[64], sub[80]; for (i = 0; i < dirs; ++i) { if (i % 2 == 0) { p_snprintf(buf, sizeof(buf), "%s/dir%02d", root, i); cl_git_pass(git_futils_mkdir(buf, 0775, GIT_MKDIR_PATH)); p_snprintf(buf, sizeof(buf), "%s/dir%02d/file", root, i); cl_git_mkfile(buf, buf); buf[strlen(buf) - 5] = '\0'; } else { p_snprintf(buf, sizeof(buf), "%s/DIR%02d", root, i); cl_git_pass(git_futils_mkdir(buf, 0775, GIT_MKDIR_PATH)); } for (j = 0; j < subs; ++j) { switch (j % 4) { case 0: p_snprintf(sub, sizeof(sub), "%s/sub%02d", buf, j); break; case 1: p_snprintf(sub, sizeof(sub), "%s/sUB%02d", buf, j); break; case 2: p_snprintf(sub, sizeof(sub), "%s/Sub%02d", buf, j); break; case 3: p_snprintf(sub, sizeof(sub), "%s/SUB%02d", buf, j); break; } cl_git_pass(git_futils_mkdir(sub, 0775, GIT_MKDIR_PATH)); if (j % 2 == 0) { size_t sublen = strlen(sub); memcpy(&sub[sublen], "/file", sizeof("/file")); cl_git_mkfile(sub, sub); sub[sublen] = '\0'; } } } }
/* make sure non-empty dir cannot be deleted recusively */ void test_core_rmdir__fail_to_delete_non_empty_dir(void) { git_buf file = GIT_BUF_INIT; cl_git_pass(git_buf_joinpath(&file, empty_tmp_dir, "/two/file.txt")); cl_git_mkfile(git_buf_cstr(&file), "dummy"); cl_git_fail(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY)); cl_must_pass(p_unlink(file.ptr)); cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY)); git_buf_dispose(&file); }
/* make sure GIT_FILEBUF_APPEND works as expected */ void test_core_filebuf__1(void) { git_filebuf file = GIT_FILEBUF_INIT; char test[] = "test"; cl_git_mkfile(test, "libgit2 rocks\n"); cl_git_pass(git_filebuf_open(&file, test, GIT_FILEBUF_APPEND, 0666)); cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks")); cl_git_pass(git_filebuf_commit(&file)); cl_assert_equal_file("libgit2 rocks\nlibgit2 rocks\n", 0, test); cl_must_pass(p_unlink(test)); }
void test_filter_query__initialize(void) { g_repo = cl_git_sandbox_init("crlf"); cl_git_mkfile("crlf/.gitattributes", "*.txt text\n" "*.bin binary\n" "*.crlf text eol=crlf\n" "*.lf text eol=lf\n" "*.binident binary ident\n" "*.ident text ident\n" "*.identcrlf ident text eol=crlf\n" "*.identlf ident text eol=lf\n" "*.custom custom ident text\n"); }
void test_checkout_index__donot_overwrite_modified_file_by_default(void) { git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; cl_git_mkfile("./testrepo/new.txt", "This isn't what's stored!"); /* set this up to not return an error code on conflicts, but it * still will not have permission to overwrite anything... */ opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS; cl_git_pass(git_checkout_index(g_repo, NULL, &opts)); test_file_contents("./testrepo/new.txt", "This isn't what's stored!"); }
void test_status_ignore__do_not_unignore_basename_prefix(void) { static const char *test_files[] = { "empty_standard_repo/foo_bar.txt", NULL }; make_test_data("empty_standard_repo", test_files); cl_git_mkfile( "empty_standard_repo/.gitignore", "foo_bar.txt\n" "!bar.txt\n"); assert_is_ignored("foo_bar.txt"); }
void test_core_posix__utimes(void) { struct timeval times[2]; struct stat st; time_t curtime; int fd; /* test p_utimes */ times[0].tv_sec = 1234567890; times[0].tv_usec = 0; times[1].tv_sec = 1234567890; times[1].tv_usec = 0; cl_git_mkfile("foo", "Dummy file."); cl_must_pass(p_utimes("foo", times)); p_stat("foo", &st); cl_assert_equal_i(1234567890, st.st_atime); cl_assert_equal_i(1234567890, st.st_mtime); /* test p_futimes */ times[0].tv_sec = 1414141414; times[0].tv_usec = 0; times[1].tv_sec = 1414141414; times[1].tv_usec = 0; cl_must_pass(fd = p_open("foo", O_RDWR)); cl_must_pass(p_futimes(fd, times)); p_close(fd); p_stat("foo", &st); cl_assert_equal_i(1414141414, st.st_atime); cl_assert_equal_i(1414141414, st.st_mtime); /* test p_utimes with current time, assume that * it takes < 5 seconds to get the time...! */ cl_must_pass(p_utimes("foo", NULL)); curtime = time(NULL); p_stat("foo", &st); cl_assert((st.st_atime - curtime) < 5); cl_assert((st.st_mtime - curtime) < 5); p_unlink("foo"); }
static void set_gitattributes_to(const char *driver) { git_buf line = GIT_BUF_INIT; if (driver && strcmp(driver, "")) git_buf_printf(&line, "automergeable.txt merge=%s\n", driver); else if (driver) git_buf_printf(&line, "automergeable.txt merge\n"); else git_buf_printf(&line, "automergeable.txt -merge\n"); cl_assert(!git_buf_oom(&line)); cl_git_mkfile(TEST_REPO_PATH "/.gitattributes", line.ptr); git_buf_dispose(&line); }
void test_core_rmdir__can_skip__non_empty_dir(void) { git_buf file = GIT_BUF_INIT; cl_git_pass(git_buf_joinpath(&file, empty_tmp_dir, "/two/file.txt")); cl_git_mkfile(git_buf_cstr(&file), "dummy"); cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, GIT_DIRREMOVAL_ONLY_EMPTY_DIRS)); cl_assert(git_path_exists(git_buf_cstr(&file)) == true); cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, GIT_DIRREMOVAL_FILES_AND_DIRS)); cl_assert(git_path_exists(empty_tmp_dir) == false); git_buf_free(&file); }
void test_checkout_index__options_disable_filters(void) { cl_git_mkfile("./testrepo/.gitattributes", "*.txt text eol=crlf\n"); g_opts.disable_filters = false; cl_git_pass(git_checkout_index(g_repo, &g_opts)); test_file_contents("./testrepo/new.txt", "my new file\r\n"); p_unlink("./testrepo/new.txt"); g_opts.disable_filters = true; cl_git_pass(git_checkout_index(g_repo, &g_opts)); test_file_contents("./testrepo/new.txt", "my new file\n"); }
void test_submodule_nosubs__lookup(void) { git_repository *repo = cl_git_sandbox_init("status"); git_submodule *sm = NULL; p_mkdir("status/subrepo", 0777); cl_git_mkfile("status/subrepo/.git", "gitdir: ../.git"); cl_assert_equal_i(GIT_ENOTFOUND, git_submodule_lookup(&sm, repo, "subdir")); cl_assert_equal_i(GIT_EEXISTS, git_submodule_lookup(&sm, repo, "subrepo")); cl_assert_equal_i(GIT_ENOTFOUND, git_submodule_lookup(&sm, repo, "subdir")); cl_assert_equal_i(GIT_EEXISTS, git_submodule_lookup(&sm, repo, "subrepo")); }
void test_core_rmdir__can_skip_non_empty_dir(void) { git_buf file = GIT_BUF_INIT; cl_git_pass(git_buf_joinpath(&file, empty_tmp_dir, "/two/file.txt")); cl_git_mkfile(git_buf_cstr(&file), "dummy"); cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_SKIP_NONEMPTY)); cl_assert(git_path_exists(git_buf_cstr(&file)) == true); cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_REMOVE_FILES)); cl_assert(git_path_exists(empty_tmp_dir) == false); git_buf_dispose(&file); }
void test_stash_save__ignored_directory(void) { cl_git_pass(p_mkdir("stash/ignored_directory", 0777)); cl_git_pass(p_mkdir("stash/ignored_directory/sub", 0777)); cl_git_mkfile("stash/ignored_directory/sub/some_file", "stuff"); assert_status(repo, "ignored_directory/sub/some_file", GIT_STATUS_WT_NEW); cl_git_pass(git_ignore_add_rule(repo, "ignored_directory/")); assert_status(repo, "ignored_directory/sub/some_file", GIT_STATUS_IGNORED); cl_git_pass(git_stash_save(&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED | GIT_STASH_INCLUDE_IGNORED)); cl_assert(!git_path_exists("stash/ignored_directory/sub/some_file")); cl_assert(!git_path_exists("stash/ignored_directory/sub")); cl_assert(!git_path_exists("stash/ignored_directory")); }
void test_revwalk_basic__glob_heads_with_invalid(void) { int i; git_oid oid; revwalk_basic_setup_walk("testrepo"); cl_git_mkfile("testrepo/.git/refs/heads/garbage", "not-a-ref"); cl_git_pass(git_revwalk_push_glob(_walk, "heads")); for (i = 0; !git_revwalk_next(&oid, _walk); ++i) /* walking */; /* git log --branches --oneline | wc -l => 16 */ cl_assert_equal_i(17, i); }
void test_stash_apply__initialize(void) { git_oid oid; repo = cl_git_sandbox_init_new("stash"); cl_git_pass(git_repository_index(&repo_index, repo)); cl_git_pass(git_signature_new(&signature, "nulltoken", "*****@*****.**", 1323847743, 60)); /* Wed Dec 14 08:29:03 2011 +0100 */ cl_git_mkfile("stash/what", "hello\n"); cl_git_mkfile("stash/how", "small\n"); cl_git_mkfile("stash/who", "world\n"); cl_git_mkfile("stash/where", "meh\n"); cl_git_pass(git_index_add_bypath(repo_index, "what")); cl_git_pass(git_index_add_bypath(repo_index, "how")); cl_git_pass(git_index_add_bypath(repo_index, "who")); cl_repo_commit_from_index(NULL, repo, signature, 0, "Initial commit"); cl_git_rewritefile("stash/what", "goodbye\n"); cl_git_rewritefile("stash/who", "funky world\n"); cl_git_mkfile("stash/when", "tomorrow\n"); cl_git_mkfile("stash/why", "would anybody use stash?\n"); cl_git_mkfile("stash/where", "????\n"); cl_git_pass(git_index_add_bypath(repo_index, "who")); cl_git_pass(git_index_add_bypath(repo_index, "why")); cl_git_pass(git_index_add_bypath(repo_index, "where")); git_index_write(repo_index); cl_git_rewritefile("stash/where", "....\n"); /* Pre-stash state */ assert_status(repo, "what", GIT_STATUS_WT_MODIFIED); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_INDEX_MODIFIED); assert_status(repo, "when", GIT_STATUS_WT_NEW); assert_status(repo, "why", GIT_STATUS_INDEX_NEW); assert_status(repo, "where", GIT_STATUS_INDEX_NEW|GIT_STATUS_WT_MODIFIED); cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); /* Post-stash state */ assert_status(repo, "what", GIT_STATUS_CURRENT); assert_status(repo, "how", GIT_STATUS_CURRENT); assert_status(repo, "who", GIT_STATUS_CURRENT); assert_status(repo, "when", GIT_ENOTFOUND); assert_status(repo, "why", GIT_ENOTFOUND); assert_status(repo, "where", GIT_ENOTFOUND); }
void test_config_write__to_file_with_only_comment(void) { git_config *cfg; const char *filename = "config-file"; git_buf result = GIT_BUF_INIT; cl_git_mkfile(filename, "\n\n"); cl_git_pass(git_config_open_ondisk(&cfg, filename)); cl_git_pass(git_config_set_string(cfg, "section.name", "value")); git_config_free(cfg); cl_git_pass(git_futils_readbuffer(&result, "config-file")); cl_assert_equal_s("\n\n[section]\n\tname = value\n", result.ptr); git_buf_free(&result); }
void test_index_crlf__autocrlf_input_no_attrs(void) { const git_index_entry *entry; git_oid oid; cl_repo_set_string(g_repo, "core.autocrlf", "input"); cl_git_mkfile("./crlf/newfile.txt", (GIT_EOL_NATIVE == GIT_EOL_CRLF) ? FILE_CONTENTS_CRLF : FILE_CONTENTS_LF); cl_git_pass(git_index_add_bypath(g_index, "newfile.txt")); entry = git_index_get_bypath(g_index, "newfile.txt", 0); cl_git_pass(git_oid_fromstr(&oid, FILE_OID_LF)); cl_assert(git_oid_cmp(&oid, &entry->id) == 0); }
void test_status_ignore__empty_repo_with_gitignore_rewrite(void) { status_entry_single st; int ignored; g_repo = cl_git_sandbox_init("empty_standard_repo"); cl_git_mkfile( "empty_standard_repo/look-ma.txt", "I'm going to be ignored!"); memset(&st, 0, sizeof(st)); cl_git_pass(git_status_foreach(g_repo, cb_status__single, &st)); cl_assert(st.count == 1); cl_assert(st.status == GIT_STATUS_WT_NEW); cl_git_pass(git_status_file(&st.status, g_repo, "look-ma.txt")); cl_assert(st.status == GIT_STATUS_WT_NEW); cl_git_pass(git_status_should_ignore(&ignored, g_repo, "look-ma.txt")); cl_assert(!ignored); cl_git_rewritefile("empty_standard_repo/.gitignore", "*.nomatch\n"); memset(&st, 0, sizeof(st)); cl_git_pass(git_status_foreach(g_repo, cb_status__single, &st)); cl_assert(st.count == 2); cl_assert(st.status == GIT_STATUS_WT_NEW); cl_git_pass(git_status_file(&st.status, g_repo, "look-ma.txt")); cl_assert(st.status == GIT_STATUS_WT_NEW); cl_git_pass(git_status_should_ignore(&ignored, g_repo, "look-ma.txt")); cl_assert(!ignored); cl_git_rewritefile("empty_standard_repo/.gitignore", "*.txt\n"); memset(&st, 0, sizeof(st)); cl_git_pass(git_status_foreach(g_repo, cb_status__single, &st)); cl_assert(st.count == 2); cl_assert(st.status == GIT_STATUS_IGNORED); cl_git_pass(git_status_file(&st.status, g_repo, "look-ma.txt")); cl_assert(st.status == GIT_STATUS_IGNORED); cl_git_pass(git_status_should_ignore(&ignored, g_repo, "look-ma.txt")); cl_assert(ignored); }
void test_index_rename__single_file(void) { git_repository *repo; git_index *index; size_t position; git_oid expected; const git_index_entry *entry; p_mkdir("rename", 0700); cl_git_pass(git_repository_init(&repo, "./rename", 0)); cl_git_pass(git_repository_index(&index, repo)); cl_assert(git_index_entrycount(index) == 0); cl_git_mkfile("./rename/lame.name.txt", "new_file\n"); /* This should add a new blob to the object database in 'd4/fa8600b4f37d7516bef4816ae2c64dbf029e3a' */ cl_git_pass(git_index_add_bypath(index, "lame.name.txt")); cl_assert(git_index_entrycount(index) == 1); cl_git_pass(git_oid_fromstr(&expected, "d4fa8600b4f37d7516bef4816ae2c64dbf029e3a")); cl_assert(!git_index_find(&position, index, "lame.name.txt")); entry = git_index_get_byindex(index, position); cl_assert_equal_oid(&expected, &entry->id); /* This removes the entry from the index, but not from the object database */ cl_git_pass(git_index_remove(index, "lame.name.txt", 0)); cl_assert(git_index_entrycount(index) == 0); p_rename("./rename/lame.name.txt", "./rename/fancy.name.txt"); cl_git_pass(git_index_add_bypath(index, "fancy.name.txt")); cl_assert(git_index_entrycount(index) == 1); cl_assert(!git_index_find(&position, index, "fancy.name.txt")); entry = git_index_get_byindex(index, position); cl_assert_equal_oid(&expected, &entry->id); git_index_free(index); git_repository_free(repo); cl_fixture_cleanup("rename"); }