Fix tests to use core.filemode correctly Some windows tests were failing
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
diff --git a/tests-clar/clar_libgit2.c b/tests-clar/clar_libgit2.c
index bf35a68..340943c 100644
--- a/tests-clar/clar_libgit2.c
+++ b/tests-clar/clar_libgit2.c
@@ -344,3 +344,13 @@ void cl_repo_set_bool(git_repository *repo, const char *cfg, int value)
cl_git_pass(git_config_set_bool(config, cfg, value != 0));
git_config_free(config);
}
+
+int cl_repo_get_bool(git_repository *repo, const char *cfg)
+{
+ int val = 0;
+ git_config *config;
+ cl_git_pass(git_repository_config(&config, repo));
+ cl_git_pass(git_config_get_bool(&val, config, cfg));;
+ git_config_free(config);
+ return val;
+}
diff --git a/tests-clar/clar_libgit2.h b/tests-clar/clar_libgit2.h
index 080d32b..3cb0607 100644
--- a/tests-clar/clar_libgit2.h
+++ b/tests-clar/clar_libgit2.h
@@ -88,5 +88,6 @@ int cl_git_remove_placeholders(const char *directory_path, const char *filename)
/* config setting helpers */
void cl_repo_set_bool(git_repository *repo, const char *cfg, int value);
+int cl_repo_get_bool(git_repository *repo, const char *cfg);
#endif
diff --git a/tests-clar/repo/init.c b/tests-clar/repo/init.c
index aeb35d3..62e4ecd 100644
--- a/tests-clar/repo/init.c
+++ b/tests-clar/repo/init.c
@@ -270,7 +270,6 @@ void test_repo_init__reinit_doesnot_overwrite_ignorecase(void)
void test_repo_init__reinit_overwrites_filemode(void)
{
- git_config *config;
int expected, current_value;
#ifdef GIT_WIN32
@@ -291,13 +290,10 @@ void test_repo_init__reinit_overwrites_filemode(void)
/* Reinit the repository */
cl_git_pass(git_repository_init(&_repo, "overwrite.git", 1));
- git_repository_config(&config, _repo);
/* Ensure the "core.filemode" config value has been reset */
- cl_git_pass(git_config_get_bool(¤t_value, config, "core.filemode"));
+ current_value = cl_repo_get_bool(_repo, "core.filemode");
cl_assert_equal_i(expected, current_value);
-
- git_config_free(config);
}
void test_repo_init__sets_logAllRefUpdates_according_to_type_of_repository(void)
@@ -391,8 +387,8 @@ static void assert_hooks_match(
(((expected_st.st_mode & 0111) ? 0100777 : 0100666) & ~g_umask);
if (!core_filemode) {
- expected_st.st_mode = expected_st.st_mode & ~0111;
- st.st_mode = st.st_mode & ~0111;
+ expected_st.st_mode = expected_st.st_mode & ~0177;
+ st.st_mode = st.st_mode & ~0177;
}
cl_assert_equal_i_fmt(expected_st.st_mode, st.st_mode, "%07o");
@@ -438,6 +434,7 @@ void test_repo_init__extended_with_template(void)
git_buf expected = GIT_BUF_INIT;
git_buf actual = GIT_BUF_INIT;
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
+ int filemode;
cl_set_cleanup(&cleanup_repository, "templated.git");
@@ -461,13 +458,15 @@ void test_repo_init__extended_with_template(void)
git_buf_free(&expected);
git_buf_free(&actual);
+ filemode = cl_repo_get_bool(_repo, "core.filemode");
+
assert_hooks_match(
cl_fixture("template"), git_repository_path(_repo),
- "hooks/update.sample", true);
+ "hooks/update.sample", filemode);
assert_hooks_match(
cl_fixture("template"), git_repository_path(_repo),
- "hooks/link.sample", true);
+ "hooks/link.sample", filemode);
}
void test_repo_init__extended_with_template_and_shared_mode(void)
@@ -475,7 +474,6 @@ void test_repo_init__extended_with_template_and_shared_mode(void)
git_buf expected = GIT_BUF_INIT;
git_buf actual = GIT_BUF_INIT;
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
- git_config *config;
int filemode = true;
const char *repo_path = NULL;
@@ -491,9 +489,7 @@ void test_repo_init__extended_with_template_and_shared_mode(void)
cl_assert(!git_repository_is_bare(_repo));
cl_assert(!git__suffixcmp(git_repository_path(_repo), "/init_shared_from_tpl/.git/"));
- cl_git_pass(git_repository_config(&config, _repo));
- cl_git_pass(git_config_get_bool(&filemode, config, "core.filemode"));
- git_config_free(config);
+ filemode = cl_repo_get_bool(_repo, "core.filemode");
cl_git_pass(git_futils_readbuffer(
&expected, cl_fixture("template/description")));