3 #include "repository.h"
6 #define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
8 void prepare_repo_settings(struct repository *r)
13 if (r->settings.initialized)
17 memset(&r->settings, -1, sizeof(r->settings));
19 if (!repo_config_get_bool(r, "core.commitgraph", &value))
20 r->settings.core_commit_graph = value;
21 if (!repo_config_get_bool(r, "commitgraph.readchangedpaths", &value))
22 r->settings.commit_graph_read_changed_paths = value;
23 if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
24 r->settings.gc_write_commit_graph = value;
25 UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
26 UPDATE_DEFAULT_BOOL(r->settings.commit_graph_read_changed_paths, 1);
27 UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
29 if (!repo_config_get_int(r, "index.version", &value))
30 r->settings.index_version = value;
31 if (!repo_config_get_maybe_bool(r, "core.untrackedcache", &value)) {
33 r->settings.core_untracked_cache = UNTRACKED_CACHE_REMOVE;
35 r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
36 } else if (!repo_config_get_string(r, "core.untrackedcache", &strval)) {
37 if (!strcasecmp(strval, "keep"))
38 r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
43 if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
44 if (!strcasecmp(strval, "skipping"))
45 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
46 else if (!strcasecmp(strval, "noop"))
47 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
49 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
52 if (!repo_config_get_bool(r, "pack.usesparse", &value))
53 r->settings.pack_use_sparse = value;
54 UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
56 value = git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0);
57 if (value || !repo_config_get_bool(r, "core.multipackindex", &value))
58 r->settings.core_multi_pack_index = value;
59 UPDATE_DEFAULT_BOOL(r->settings.core_multi_pack_index, 1);
61 if (!repo_config_get_bool(r, "core.usebuiltinfsmonitor", &value) && value)
62 r->settings.use_builtin_fsmonitor = 1;
64 if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
65 UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
66 UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
69 if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value))
70 r->settings.fetch_write_commit_graph = value;
71 UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 0);
73 if (!repo_config_get_bool(r, "feature.experimental", &value) && value)
74 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
76 /* Hack for test programs like test-dump-untracked-cache */
77 if (ignore_untracked_cache_config)
78 r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
80 UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_KEEP);
82 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT);
85 * This setting guards all index reads to require a full index
86 * over a sparse index. After suitable guards are placed in the
87 * codebase around uses of the index, this setting will be
90 r->settings.command_requires_full_index = 1;
93 * Initialize this as off.
95 r->settings.sparse_index = 0;
96 if (!repo_config_get_bool(r, "index.sparse", &value) && value)
97 r->settings.sparse_index = 1;