repository: enhance reinitialization test coverage
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
diff --git a/tests-clar/repo/init.c b/tests-clar/repo/init.c
index 1ba355e..f9e781e 100644
--- a/tests-clar/repo/init.c
+++ b/tests-clar/repo/init.c
@@ -242,6 +242,37 @@ void test_repo_init__reinit_doesnot_overwrite_ignorecase(void)
git_config_free(config);
}
+void test_repo_init__reinit_overwrites_filemode(void)
+{
+ git_config *config;
+ int expected, current_value;
+
+#ifdef GIT_WIN32
+ expected = false;
+#else
+ expected = true;
+#endif
+
+ /* Init a new repo */
+ cl_git_pass(git_repository_init(&_repo, "config_entry/test.git", 1));
+
+ /* Change the "core.filemode" config value to something unlikely */
+ git_repository_config(&config, _repo);
+ git_config_set_bool(config, "core.filemode", !expected);
+ git_config_free(config);
+ git_repository_free(_repo);
+
+ /* Reinit the repository */
+ cl_git_pass(git_repository_init(&_repo, "config_entry/test.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"));
+ cl_assert_equal_i(expected, current_value);
+
+ git_config_free(config);
+}
+
void test_repo_init__sets_logAllRefUpdates_according_to_type_of_repository(void)
{
assert_config_entry_on_init_bytype("core.logallrefupdates", GIT_ENOTFOUND, true);