checkout test: only run icase on icase platform
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
diff --git a/tests/checkout/icase.c b/tests/checkout/icase.c
index ae1a63b..82ad01e 100644
--- a/tests/checkout/icase.c
+++ b/tests/checkout/icase.c
@@ -1,6 +1,7 @@
#include "clar_libgit2.h"
#include "git2/checkout.h"
+#include "refs.h"
#include "path.h"
#ifdef GIT_WIN32
@@ -14,9 +15,18 @@ static git_checkout_options checkout_opts;
void test_checkout_icase__initialize(void)
{
git_oid id;
+ git_config *cfg;
+ int icase = 0;
repo = cl_git_sandbox_init("testrepo");
+ cl_git_pass(git_repository_config_snapshot(&cfg, repo));
+ git_config_get_bool(&icase, cfg, "core.ignorecase");
+ git_config_free(cfg);
+
+ if (!icase)
+ cl_skip();
+
cl_git_pass(git_reference_name_to_id(&id, repo, "refs/heads/dir"));
cl_git_pass(git_object_lookup(&obj, repo, &id, GIT_OBJ_ANY));
@@ -212,3 +222,54 @@ void test_checkout_icase__overwrites_links_for_folders_when_forced(void)
cl_assert(!git_path_exists("b.txt"));
assert_name_is("testrepo/a");
}
+
+void test_checkout_icase__ignores_unstaged_casechange(void)
+{
+ git_reference *orig_ref, *br2_ref;
+ git_commit *orig, *br2;
+ 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, repo, "HEAD", 100));
+ cl_git_pass(git_commit_lookup(&orig, repo, git_reference_target(orig_ref)));
+ cl_git_pass(git_reset(repo, (git_object *)orig, GIT_RESET_HARD, NULL));
+
+ cl_rename("testrepo/branch_file.txt", "testrepo/Branch_File.txt");
+
+ cl_git_pass(git_reference_lookup_resolved(&br2_ref, repo, "refs/heads/br2", 100));
+ cl_git_pass(git_commit_lookup(&br2, repo, git_reference_target(br2_ref)));
+
+ cl_git_pass(git_checkout_tree(repo, (const git_object *)br2, &checkout_opts));
+
+ git_commit_free(orig);
+ git_reference_free(orig_ref);
+}
+
+void test_checkout_icase__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, repo, "HEAD", 100));
+ cl_git_pass(git_object_lookup(&orig, repo, git_reference_target(orig_ref), GIT_OBJ_COMMIT));
+ cl_git_pass(git_reset(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, repo, "refs/heads/subtrees"));
+ cl_git_pass(git_object_lookup(&subtrees, repo, &oid, GIT_OBJ_ANY));
+
+ cl_git_fail(git_checkout_tree(repo, subtrees, &checkout_opts));
+
+ git_object_free(orig);
+ git_object_free(subtrees);
+ git_reference_free(orig_ref);
+}
+
diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c
index 3bc9c93..50541a7 100644
--- a/tests/checkout/tree.c
+++ b/tests/checkout/tree.c
@@ -1338,82 +1338,3 @@ void test_checkout_tree__safe_proceeds_if_no_index(void)
git_object_free(obj);
}
-void test_checkout_tree__ignores_unstaged_casechange(void)
-{
- git_reference *orig_ref, *br2_ref;
- git_commit *orig, *br2;
- 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_commit_lookup(&orig, g_repo, git_reference_target(orig_ref)));
- cl_git_pass(git_reset(g_repo, (git_object *)orig, GIT_RESET_HARD, NULL));
-
- cl_rename("testrepo/branch_file.txt", "testrepo/Branch_File.txt");
-
- cl_git_pass(git_reference_lookup_resolved(&br2_ref, g_repo, "refs/heads/br2", 100));
- cl_git_pass(git_commit_lookup(&br2, g_repo, git_reference_target(br2_ref)));
-
- cl_git_pass(git_checkout_tree(g_repo, (const git_object *)br2, &checkout_opts));
-
- 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);
-}