summaryrefslogtreecommitdiff
path: root/tests-clar/repo/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests-clar/repo/init.c')
-rw-r--r--tests-clar/repo/init.c81
1 files changed, 42 insertions, 39 deletions
diff --git a/tests-clar/repo/init.c b/tests-clar/repo/init.c
index 392be205b..617fdf879 100644
--- a/tests-clar/repo/init.c
+++ b/tests-clar/repo/init.c
@@ -179,41 +179,32 @@ void test_repo_init__additional_templates(void)
git_buf_free(&path);
}
-static void assert_config_entry_on_init_bytype(const char *config_key, int expected_value, bool is_bare)
+static void assert_config_entry_on_init_bytype(
+ const char *config_key, int expected_value, bool is_bare)
{
git_config *config;
- int current_value;
- git_buf repo_path = GIT_BUF_INIT;
+ int error, current_value;
+ const char *repo_path = is_bare ?
+ "config_entry/test.bare.git" : "config_entry/test.non.bare.git";
cl_set_cleanup(&cleanup_repository, "config_entry");
- cl_git_pass(git_buf_puts(&repo_path, "config_entry/test."));
-
- if (!is_bare)
- cl_git_pass(git_buf_puts(&repo_path, "non."));
-
- cl_git_pass(git_buf_puts(&repo_path, "bare.git"));
-
- cl_git_pass(git_repository_init(&_repo, git_buf_cstr(&repo_path), is_bare));
+ cl_git_pass(git_repository_init(&_repo, repo_path, is_bare));
- git_buf_free(&repo_path);
-
- git_repository_config(&config, _repo);
+ cl_git_pass(git_repository_config(&config, _repo));
+ error = git_config_get_bool(&current_value, config, config_key);
+ git_config_free(config);
if (expected_value >= 0) {
- cl_git_pass(git_config_get_bool(&current_value, config, config_key));
-
+ cl_assert_equal_i(0, error);
cl_assert_equal_i(expected_value, current_value);
} else {
- int error = git_config_get_bool(&current_value, config, config_key);
-
cl_assert_equal_i(expected_value, error);
}
-
- git_config_free(config);
}
-static void assert_config_entry_on_init(const char *config_key, int expected_value)
+static void assert_config_entry_on_init(
+ const char *config_key, int expected_value)
{
assert_config_entry_on_init_bytype(config_key, expected_value, true);
git_repository_free(_repo);
@@ -223,21 +214,36 @@ static void assert_config_entry_on_init(const char *config_key, int expected_val
void test_repo_init__detect_filemode(void)
{
-#ifdef GIT_WIN32
- assert_config_entry_on_init("core.filemode", false);
-#else
- assert_config_entry_on_init("core.filemode", true);
-#endif
+ assert_config_entry_on_init("core.filemode", cl_is_chmod_supported());
}
-#define CASE_INSENSITIVE_FILESYSTEM (defined GIT_WIN32 || defined __APPLE__)
-
void test_repo_init__detect_ignorecase(void)
{
-#if CASE_INSENSITIVE_FILESYSTEM
- assert_config_entry_on_init("core.ignorecase", true);
+ struct stat st;
+ bool found_without_match;
+
+ cl_git_write2file("testCAPS", "whatever\n", 0, O_CREAT | O_WRONLY, 0666);
+ found_without_match = (p_stat("Testcaps", &st) == 0);
+ cl_must_pass(p_unlink("testCAPS"));
+
+ assert_config_entry_on_init(
+ "core.ignorecase", found_without_match ? true : GIT_ENOTFOUND);
+}
+
+void test_repo_init__detect_precompose_unicode_required(void)
+{
+ char *composed = "ḱṷṓn", *decomposed = "ḱṷṓn";
+ struct stat st;
+ bool found_with_nfd;
+
+ cl_git_write2file(composed, "whatever\n", 0, O_CREAT | O_WRONLY, 0666);
+ found_with_nfd = (p_stat(decomposed, &st) == 0);
+ cl_must_pass(p_unlink(composed));
+
+#ifdef GIT_USE_ICONV
+ assert_config_entry_on_init("core.precomposeunicode", found_with_nfd);
#else
- assert_config_entry_on_init("core.ignorecase", GIT_ENOTFOUND);
+ assert_config_entry_on_init("core.precomposeunicode", GIT_ENOTFOUND);
#endif
}
@@ -270,13 +276,7 @@ void test_repo_init__reinit_doesnot_overwrite_ignorecase(void)
void test_repo_init__reinit_overwrites_filemode(void)
{
- int expected, current_value;
-
-#ifdef GIT_WIN32
- expected = false;
-#else
- expected = true;
-#endif
+ int expected = cl_is_chmod_supported(), current_value;
/* Init a new repo */
cl_set_cleanup(&cleanup_repository, "overwrite.git");
@@ -348,7 +348,10 @@ void test_repo_init__extended_1(void)
cl_git_pass(git_path_lstat(git_repository_path(_repo), &st));
cl_assert(S_ISDIR(st.st_mode));
- cl_assert((S_ISGID & st.st_mode) == S_ISGID);
+ if (cl_is_chmod_supported())
+ cl_assert((S_ISGID & st.st_mode) == S_ISGID);
+ else
+ cl_assert((S_ISGID & st.st_mode) == 0);
cl_git_pass(git_reference_lookup(&ref, _repo, "HEAD"));
cl_assert(git_reference_type(ref) == GIT_REF_SYMBOLIC);