3 #include "repository.h"
5 #include "compat/fsmonitor/fsm-listen.h"
7 static void repo_cfg_bool(struct repository
*r
, const char *key
, int *dest
,
10 if (repo_config_get_bool(r
, key
, dest
))
14 void prepare_repo_settings(struct repository
*r
)
22 BUG("Cannot add settings for uninitialized repository");
24 if (r
->settings
.initialized
++)
28 r
->settings
.index_version
= -1;
29 r
->settings
.core_untracked_cache
= UNTRACKED_CACHE_KEEP
;
30 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_CONSECUTIVE
;
32 /* Booleans config or default, cascades to other settings */
33 repo_cfg_bool(r
, "feature.manyfiles", &manyfiles
, 0);
34 repo_cfg_bool(r
, "feature.experimental", &experimental
, 0);
36 /* Defaults modified by feature.* */
38 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_SKIPPING
;
41 r
->settings
.index_version
= 4;
42 r
->settings
.core_untracked_cache
= UNTRACKED_CACHE_WRITE
;
45 /* Boolean config or default, does not cascade (simple) */
46 repo_cfg_bool(r
, "core.commitgraph", &r
->settings
.core_commit_graph
, 1);
47 repo_cfg_bool(r
, "commitgraph.readchangedpaths", &r
->settings
.commit_graph_read_changed_paths
, 1);
48 repo_cfg_bool(r
, "gc.writecommitgraph", &r
->settings
.gc_write_commit_graph
, 1);
49 repo_cfg_bool(r
, "fetch.writecommitgraph", &r
->settings
.fetch_write_commit_graph
, 0);
50 repo_cfg_bool(r
, "pack.usesparse", &r
->settings
.pack_use_sparse
, 1);
51 repo_cfg_bool(r
, "core.multipackindex", &r
->settings
.core_multi_pack_index
, 1);
52 repo_cfg_bool(r
, "index.sparse", &r
->settings
.sparse_index
, 0);
55 * The GIT_TEST_MULTI_PACK_INDEX variable is special in that
56 * either it *or* the config sets
57 * r->settings.core_multi_pack_index if true. We don't take
58 * the environment variable if it exists (even if false) over
59 * any config, as in most other cases.
61 if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX
, 0))
62 r
->settings
.core_multi_pack_index
= 1;
67 if (!repo_config_get_int(r
, "index.version", &value
))
68 r
->settings
.index_version
= value
;
70 if (!repo_config_get_string(r
, "core.untrackedcache", &strval
)) {
71 int v
= git_parse_maybe_bool(strval
);
74 * If it's set to "keep", or some other non-boolean
75 * value then "v < 0". Then we do nothing and keep it
76 * at the default of UNTRACKED_CACHE_KEEP.
79 r
->settings
.core_untracked_cache
= v
?
80 UNTRACKED_CACHE_WRITE
: UNTRACKED_CACHE_REMOVE
;
84 if (!repo_config_get_string(r
, "fetch.negotiationalgorithm", &strval
)) {
85 int fetch_default
= r
->settings
.fetch_negotiation_algorithm
;
86 if (!strcasecmp(strval
, "skipping"))
87 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_SKIPPING
;
88 else if (!strcasecmp(strval
, "noop"))
89 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_NOOP
;
90 else if (!strcasecmp(strval
, "consecutive"))
91 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_CONSECUTIVE
;
92 else if (!strcasecmp(strval
, "default"))
93 r
->settings
.fetch_negotiation_algorithm
= fetch_default
;
95 die("unknown fetch negotiation algorithm '%s'", strval
);
99 * This setting guards all index reads to require a full index
100 * over a sparse index. After suitable guards are placed in the
101 * codebase around uses of the index, this setting will be
104 r
->settings
.command_requires_full_index
= 1;