]> git.ipfire.org Git - thirdparty/git.git/blame - repo-settings.c
cache.h: remove this no-longer-used header
[thirdparty/git.git] / repo-settings.c
CommitLineData
15db4e7f 1#include "git-compat-util.h"
7211b9e7
DS
2#include "config.h"
3#include "repository.h"
18e449f8 4#include "midx.h"
62c73671 5#include "compat/fsmonitor/fsm-listen.h"
7211b9e7 6
3050b6df
ÆAB
7static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
8 int def)
9{
10 if (repo_config_get_bool(r, key, dest))
11 *dest = def;
12}
31b1de6a 13
a92d8523
TB
14static void repo_cfg_int(struct repository *r, const char *key, int *dest,
15 int def)
16{
17 if (repo_config_get_int(r, key, dest))
18 *dest = def;
19}
20
7211b9e7
DS
21void prepare_repo_settings(struct repository *r)
22{
3050b6df 23 int experimental;
7211b9e7 24 int value;
66eede4a 25 const char *strval;
3050b6df 26 int manyfiles;
7211b9e7 27
44c7e62e
LD
28 if (!r->gitdir)
29 BUG("Cannot add settings for uninitialized repository");
30
3050b6df 31 if (r->settings.initialized++)
7211b9e7
DS
32 return;
33
34 /* Defaults */
3050b6df
ÆAB
35 r->settings.index_version = -1;
36 r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
714edc62 37 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE;
3050b6df
ÆAB
38
39 /* Booleans config or default, cascades to other settings */
40 repo_cfg_bool(r, "feature.manyfiles", &manyfiles, 0);
41 repo_cfg_bool(r, "feature.experimental", &experimental, 0);
7211b9e7 42
3050b6df 43 /* Defaults modified by feature.* */
029a632c 44 if (experimental)
3050b6df 45 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
3050b6df
ÆAB
46 if (manyfiles) {
47 r->settings.index_version = 4;
17194b19 48 r->settings.index_skip_hash = 1;
3050b6df
ÆAB
49 r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
50 }
51
a92d8523 52 /* Commit graph config or default, does not cascade (simple) */
3050b6df 53 repo_cfg_bool(r, "core.commitgraph", &r->settings.core_commit_graph, 1);
a92d8523 54 repo_cfg_int(r, "commitgraph.generationversion", &r->settings.commit_graph_generation_version, 2);
3050b6df
ÆAB
55 repo_cfg_bool(r, "commitgraph.readchangedpaths", &r->settings.commit_graph_read_changed_paths, 1);
56 repo_cfg_bool(r, "gc.writecommitgraph", &r->settings.gc_write_commit_graph, 1);
57 repo_cfg_bool(r, "fetch.writecommitgraph", &r->settings.fetch_write_commit_graph, 0);
a92d8523
TB
58
59 /* Boolean config or default, does not cascade (simple) */
3050b6df
ÆAB
60 repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1);
61 repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
c21919f1 62 repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
17194b19 63 repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);
dbcf6116 64 repo_cfg_bool(r, "pack.readreverseindex", &r->settings.pack_read_reverse_index, 1);
3050b6df
ÆAB
65
66 /*
67 * The GIT_TEST_MULTI_PACK_INDEX variable is special in that
68 * either it *or* the config sets
69 * r->settings.core_multi_pack_index if true. We don't take
70 * the environment variable if it exists (even if false) over
71 * any config, as in most other cases.
72 */
73 if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0))
74 r->settings.core_multi_pack_index = 1;
7211b9e7 75
3050b6df
ÆAB
76 /*
77 * Non-boolean config
78 */
c11e9966 79 if (!repo_config_get_int(r, "index.version", &value))
7211b9e7 80 r->settings.index_version = value;
ad0fb659 81
66eede4a 82 if (!repo_config_get_string_tmp(r, "core.untrackedcache", &strval)) {
3050b6df
ÆAB
83 int v = git_parse_maybe_bool(strval);
84
85 /*
86 * If it's set to "keep", or some other non-boolean
87 * value then "v < 0". Then we do nothing and keep it
88 * at the default of UNTRACKED_CACHE_KEEP.
89 */
90 if (v >= 0)
91 r->settings.core_untracked_cache = v ?
92 UNTRACKED_CACHE_WRITE : UNTRACKED_CACHE_REMOVE;
ad0fb659
DS
93 }
94
66eede4a 95 if (!repo_config_get_string_tmp(r, "fetch.negotiationalgorithm", &strval)) {
714edc62 96 int fetch_default = r->settings.fetch_negotiation_algorithm;
aaf633c2
DS
97 if (!strcasecmp(strval, "skipping"))
98 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
cbe566a0
JT
99 else if (!strcasecmp(strval, "noop"))
100 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
714edc62
EN
101 else if (!strcasecmp(strval, "consecutive"))
102 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE;
a68c5b9e 103 else if (!strcasecmp(strval, "default"))
714edc62 104 r->settings.fetch_negotiation_algorithm = fetch_default;
a9a136c2
EN
105 else
106 die("unknown fetch negotiation algorithm '%s'", strval);
aaf633c2
DS
107 }
108
3964fc2a
DS
109 /*
110 * This setting guards all index reads to require a full index
111 * over a sparse index. After suitable guards are placed in the
112 * codebase around uses of the index, this setting will be
113 * removed.
114 */
115 r->settings.command_requires_full_index = 1;
7211b9e7 116}