3 #include "repository.h"
6 static void repo_cfg_bool(struct repository
*r
, const char *key
, int *dest
,
9 if (repo_config_get_bool(r
, key
, dest
))
13 void prepare_repo_settings(struct repository
*r
)
21 BUG("Cannot add settings for uninitialized repository");
23 if (r
->settings
.initialized
++)
27 r
->settings
.index_version
= -1;
28 r
->settings
.core_untracked_cache
= UNTRACKED_CACHE_KEEP
;
29 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_DEFAULT
;
31 /* Booleans config or default, cascades to other settings */
32 repo_cfg_bool(r
, "feature.manyfiles", &manyfiles
, 0);
33 repo_cfg_bool(r
, "feature.experimental", &experimental
, 0);
35 /* Defaults modified by feature.* */
37 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_SKIPPING
;
40 r
->settings
.index_version
= 4;
41 r
->settings
.core_untracked_cache
= UNTRACKED_CACHE_WRITE
;
44 /* Boolean config or default, does not cascade (simple) */
45 repo_cfg_bool(r
, "core.commitgraph", &r
->settings
.core_commit_graph
, 1);
46 repo_cfg_bool(r
, "commitgraph.readchangedpaths", &r
->settings
.commit_graph_read_changed_paths
, 1);
47 repo_cfg_bool(r
, "gc.writecommitgraph", &r
->settings
.gc_write_commit_graph
, 1);
48 repo_cfg_bool(r
, "fetch.writecommitgraph", &r
->settings
.fetch_write_commit_graph
, 0);
49 repo_cfg_bool(r
, "pack.usesparse", &r
->settings
.pack_use_sparse
, 1);
50 repo_cfg_bool(r
, "core.multipackindex", &r
->settings
.core_multi_pack_index
, 1);
51 repo_cfg_bool(r
, "index.sparse", &r
->settings
.sparse_index
, 0);
54 * The GIT_TEST_MULTI_PACK_INDEX variable is special in that
55 * either it *or* the config sets
56 * r->settings.core_multi_pack_index if true. We don't take
57 * the environment variable if it exists (even if false) over
58 * any config, as in most other cases.
60 if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX
, 0))
61 r
->settings
.core_multi_pack_index
= 1;
66 if (!repo_config_get_int(r
, "index.version", &value
))
67 r
->settings
.index_version
= value
;
69 if (!repo_config_get_string(r
, "core.untrackedcache", &strval
)) {
70 int v
= git_parse_maybe_bool(strval
);
73 * If it's set to "keep", or some other non-boolean
74 * value then "v < 0". Then we do nothing and keep it
75 * at the default of UNTRACKED_CACHE_KEEP.
78 r
->settings
.core_untracked_cache
= v
?
79 UNTRACKED_CACHE_WRITE
: UNTRACKED_CACHE_REMOVE
;
83 if (!repo_config_get_string(r
, "fetch.negotiationalgorithm", &strval
)) {
84 if (!strcasecmp(strval
, "skipping"))
85 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_SKIPPING
;
86 else if (!strcasecmp(strval
, "noop"))
87 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_NOOP
;
91 * This setting guards all index reads to require a full index
92 * over a sparse index. After suitable guards are placed in the
93 * codebase around uses of the index, this setting will be
96 r
->settings
.command_requires_full_index
= 1;