Commit 64e56478ad8b3310e957701ebe234764f9f4a147

Russell Belfer 2012-06-12T09:29:56

Merge pull request #760 from nulltoken/topic/logAllRefUpdates make git_repository_init() value the core.logallrefupdates config entry

diff --git a/src/repository.c b/src/repository.c
index 7181708..4e467e6 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -718,6 +718,9 @@ static int repo_init_config(const char *git_dir, bool is_bare, bool is_reinit)
 	SET_REPO_CONFIG(int32, "core.repositoryformatversion", GIT_REPO_VERSION);
 	SET_REPO_CONFIG(bool, "core.filemode", is_chmod_supported(git_buf_cstr(&cfg_path)));
 	
+	if (!is_bare)
+		SET_REPO_CONFIG(bool, "core.logallrefupdates", true);
+
 	if (!is_reinit && is_filesystem_case_insensitive(git_dir))
 		SET_REPO_CONFIG(bool, "core.ignorecase", true);
 	/* TODO: what other defaults? */
diff --git a/tests-clar/repo/init.c b/tests-clar/repo/init.c
index af54b22..2e70c51 100644
--- a/tests-clar/repo/init.c
+++ b/tests-clar/repo/init.c
@@ -166,14 +166,14 @@ void test_repo_init__additional_templates(void)
 	git_buf_free(&path);
 }
 
-static void assert_config_entry_on_init(const char *config_key, int expected_value)
+static void assert_config_entry_on_init_bytype(const char *config_key, int expected_value, bool is_bare)
 {
 	git_config *config;
 	int current_value;
 
 	cl_set_cleanup(&cleanup_repository, "config_entry");
 	
-	cl_git_pass(git_repository_init(&_repo, "config_entry/test.git", 1));
+	cl_git_pass(git_repository_init(&_repo, "config_entry/test.git", is_bare));
 	git_repository_config(&config, _repo);
 
 	if (expected_value >= 0) {
@@ -189,6 +189,14 @@ static void assert_config_entry_on_init(const char *config_key, int expected_val
 	git_config_free(config);
 }
 
+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);
+
+	assert_config_entry_on_init_bytype(config_key, expected_value, false);
+}
+
 void test_repo_init__detect_filemode(void)
 {
 #ifdef GIT_WIN32
@@ -233,3 +241,9 @@ void test_repo_init__reinit_doesnot_overwrite_ignorecase(void)
 
 	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);
+	assert_config_entry_on_init_bytype("core.logallrefupdates", true, false);
+}