summaryrefslogtreecommitdiff
path: root/repo-settings.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2019-08-13 11:37:43 -0700
committerJunio C Hamano <gitster@pobox.com>2019-08-13 13:33:54 -0700
commit7211b9e7534e021d7c46117ec0c64482e7930560 (patch)
tree57f3ae59a21af472b6bdc8e1482f6b8d1cfb879c /repo-settings.c
parent9c9b961d7eb15fb583a2a812088713a68a85f1c0 (diff)
downloadgit-7211b9e7534e021d7c46117ec0c64482e7930560.tar.gz
repo-settings: consolidate some config settings
There are a few important config settings that are not loaded during git_default_config. These are instead loaded on-demand. Centralize these config options to a single scan, and store all of the values in a repo_settings struct. The values for each setting are initialized as negative to indicate "unset". This centralization will be particularly important in a later change to introduce "meta" config settings that change the defaults for these config settings. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repo-settings.c')
-rw-r--r--repo-settings.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/repo-settings.c b/repo-settings.c
new file mode 100644
index 0000000000..309577f6bc
--- /dev/null
+++ b/repo-settings.c
@@ -0,0 +1,25 @@
+#include "cache.h"
+#include "config.h"
+#include "repository.h"
+
+void prepare_repo_settings(struct repository *r)
+{
+ int value;
+
+ if (r->settings.initialized)
+ return;
+
+ /* Defaults */
+ memset(&r->settings, -1, sizeof(r->settings));
+
+ if (!repo_config_get_bool(r, "core.commitgraph", &value))
+ r->settings.core_commit_graph = value;
+ if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
+ r->settings.gc_write_commit_graph = value;
+
+ if (!repo_config_get_bool(r, "index.version", &value))
+ r->settings.index_version = value;
+
+ if (!repo_config_get_bool(r, "pack.usesparse", &value))
+ r->settings.pack_use_sparse = value;
+}