summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-06-20 19:05:38 -0500
committerEdward Thomson <ethomson@microsoft.com>2013-06-20 19:08:58 -0500
commitdacce80b128501e9821f254c2edb1e93906eac0b (patch)
treeeb35bc47a06474dd922d01266ce5293e4aae4d3e
parentf2d110f168e9b4b731a857d504a193de6d0974d8 (diff)
downloadlibgit2-dacce80b128501e9821f254c2edb1e93906eac0b.tar.gz
test asserting checkout should not recreate deleted files
-rw-r--r--tests-clar/checkout/tree.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c
index 462a46c83..7a1c797a2 100644
--- a/tests-clar/checkout/tree.c
+++ b/tests-clar/checkout/tree.c
@@ -442,6 +442,36 @@ void test_checkout_tree__checking_out_a_conflicting_content_change_returns_EMERG
assert_conflict("branch_file.txt", "hello\n", "5b5b025", "c47800c");
}
+void test_checkout_tree__donot_update_deleted_file_by_default(void)
+{
+ git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
+ git_oid old_id, new_id;
+ git_commit *old_commit = NULL, *new_commit = NULL;
+ git_index *index = NULL;
+
+ opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ cl_git_pass(git_oid_fromstr(&old_id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
+ cl_git_pass(git_commit_lookup(&old_commit, g_repo, &old_id));
+ cl_git_pass(git_reset(g_repo, (git_object *)old_commit, GIT_RESET_HARD));
+
+ cl_git_pass(p_unlink("testrepo/branch_file.txt"));
+ cl_git_pass(git_index_remove_bypath(index ,"branch_file.txt"));
+ cl_git_pass(git_index_write(index));
+
+ cl_assert(!git_path_exists("testrepo/branch_file.txt"));
+
+ cl_git_pass(git_oid_fromstr(&new_id, "099fabac3a9ea935598528c27f866e34089c2eff"));
+ cl_git_pass(git_commit_lookup(&new_commit, g_repo, &new_id));
+ cl_git_fail(git_checkout_tree(g_repo, (git_object *)new_commit, &opts));
+
+ git_commit_free(old_commit);
+ git_commit_free(new_commit);
+ git_index_free(index);
+}
+
void test_checkout_tree__can_checkout_with_last_workdir_item_missing(void)
{
git_index *index = NULL;