checkout test: ensure we write to casechanged dir Ensure that on a case insensitive filesystem that we can checkout into some folder 'FOLDER' that exists on disk, even if the target of the checkout is a different case (eg 'folder').
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 61 62 63 64 65
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index 46e8b0f..7b0eae4 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -1349,3 +1349,60 @@ void test_checkout_tree__ignores_unstaged_casechange(void)
git_commit_free(orig);
git_reference_free(orig_ref);
}
+
+void test_checkout_tree__conflicts_with_casechanged_subtrees(void)
+{
+ git_reference *orig_ref;
+ git_object *orig, *subtrees;
+ git_oid oid;
+ git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+ cl_git_pass(git_reference_lookup_resolved(&orig_ref, g_repo, "HEAD", 100));
+ cl_git_pass(git_object_lookup(&orig, g_repo, git_reference_target(orig_ref), GIT_OBJ_COMMIT));
+ cl_git_pass(git_reset(g_repo, (git_object *)orig, GIT_RESET_HARD, NULL));
+
+ cl_must_pass(p_mkdir("testrepo/AB", 0777));
+ cl_must_pass(p_mkdir("testrepo/AB/C", 0777));
+ cl_git_write2file("testrepo/AB/C/3.txt", "Foobar!\n", 8, O_RDWR|O_CREAT, 0666);
+
+ cl_git_pass(git_reference_name_to_id(&oid, g_repo, "refs/heads/subtrees"));
+ cl_git_pass(git_object_lookup(&subtrees, g_repo, &oid, GIT_OBJ_ANY));
+
+ cl_git_fail(git_checkout_tree(g_repo, subtrees, &checkout_opts));
+
+ git_object_free(orig);
+ git_object_free(subtrees);
+ git_reference_free(orig_ref);
+}
+
+void test_checkout_tree__checks_out_casechanged_subtrees(void)
+{
+ git_reference *orig_ref;
+ git_object *orig, *subtrees;
+ git_oid oid;
+ git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+ cl_git_pass(git_reference_lookup_resolved(&orig_ref, g_repo, "HEAD", 100));
+ cl_git_pass(git_object_lookup(&orig, g_repo, git_reference_target(orig_ref), GIT_OBJ_COMMIT));
+ cl_git_pass(git_reset(g_repo, (git_object *)orig, GIT_RESET_HARD, NULL));
+
+ cl_must_pass(p_mkdir("testrepo/AB", 0777));
+ cl_must_pass(p_mkdir("testrepo/AB/C", 0777));
+ cl_git_write2file("testrepo/AB/C/unrelated.txt", "Foobar!\n", 8, O_RDWR|O_CREAT, 0666);
+
+ cl_git_pass(git_reference_name_to_id(&oid, g_repo, "refs/heads/subtrees"));
+ cl_git_pass(git_object_lookup(&subtrees, g_repo, &oid, GIT_OBJ_ANY));
+
+ cl_git_pass(git_checkout_tree(g_repo, subtrees, &checkout_opts));
+
+ cl_assert(git_path_isfile("testrepo/ab/c/3.txt"));
+ cl_assert(git_path_isfile("testrepo/ab/c/unrelated.txt"));
+
+ git_object_free(orig);
+ git_object_free(subtrees);
+ git_reference_free(orig_ref);
+}