l10n: ru.po: update Russian translation
[git/debian.git] / repo-settings.c
blob2dfcb2b6542f2cbe75d4575e8b707cf1676679a3
1 #include "cache.h"
2 #include "config.h"
3 #include "repository.h"
4 #include "midx.h"
5 #include "compat/fsmonitor/fsm-listen.h"
7 static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
8 int def)
10 if (repo_config_get_bool(r, key, dest))
11 *dest = def;
14 void prepare_repo_settings(struct repository *r)
16 int experimental;
17 int value;
18 char *strval;
19 int manyfiles;
21 if (!r->gitdir)
22 BUG("Cannot add settings for uninitialized repository");
24 if (r->settings.initialized++)
25 return;
27 /* Defaults */
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.* */
37 if (experimental) {
38 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
40 if (manyfiles) {
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;
65 * Non-boolean config
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.
78 if (v >= 0)
79 r->settings.core_untracked_cache = v ?
80 UNTRACKED_CACHE_WRITE : UNTRACKED_CACHE_REMOVE;
81 free(strval);
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;
94 else
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
102 * removed.
104 r->settings.command_requires_full_index = 1;