summaryrefslogtreecommitdiff
path: root/tests-clar/checkout/tree.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-06-21 11:20:54 -0700
committerRussell Belfer <rb@github.com>2013-06-21 11:20:54 -0700
commit36fd9e30651cf0d6b0ef58452ba2974a3544d4d1 (patch)
tree0c39eb9beb26079d3d820d8dec0324a96956d15c /tests-clar/checkout/tree.c
parentdacce80b128501e9821f254c2edb1e93906eac0b (diff)
downloadlibgit2-36fd9e30651cf0d6b0ef58452ba2974a3544d4d1.tar.gz
Fix checkout of modified file when missing from wd
This fixes the checkout case when a file is modified between the baseline and the target and yet missing in the working directory. The logic for that case appears to have been wrong. This also adds a useful checkout notify callback to the checkout test helpers that will count notifications and also has a debug mode to visualize what checkout thinks that it's doing.
Diffstat (limited to 'tests-clar/checkout/tree.c')
-rw-r--r--tests-clar/checkout/tree.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c
index 7a1c797a2..5835ab05b 100644
--- a/tests-clar/checkout/tree.c
+++ b/tests-clar/checkout/tree.c
@@ -448,9 +448,15 @@ void test_checkout_tree__donot_update_deleted_file_by_default(void)
git_oid old_id, new_id;
git_commit *old_commit = NULL, *new_commit = NULL;
git_index *index = NULL;
+ checkout_counts ct;
opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+ memset(&ct, 0, sizeof(ct));
+ opts.notify_flags = GIT_CHECKOUT_NOTIFY_ALL;
+ opts.notify_cb = checkout_count_callback;
+ opts.notify_payload = &ct;
+
cl_git_pass(git_repository_index(&index, g_repo));
cl_git_pass(git_oid_fromstr(&old_id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
@@ -465,8 +471,13 @@ void test_checkout_tree__donot_update_deleted_file_by_default(void)
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));
+ cl_assert_equal_i(1, ct.n_conflicts);
+ cl_assert_equal_i(1, ct.n_updates);
+
git_commit_free(old_commit);
git_commit_free(new_commit);
git_index_free(index);