]>
Commit | Line | Data |
---|---|---|
7211b9e7 DS |
1 | #include "cache.h" |
2 | #include "config.h" | |
3 | #include "repository.h" | |
18e449f8 | 4 | #include "midx.h" |
7211b9e7 | 5 | |
3050b6df ÆAB |
6 | static void repo_cfg_bool(struct repository *r, const char *key, int *dest, |
7 | int def) | |
8 | { | |
9 | if (repo_config_get_bool(r, key, dest)) | |
10 | *dest = def; | |
11 | } | |
31b1de6a | 12 | |
7211b9e7 DS |
13 | void prepare_repo_settings(struct repository *r) |
14 | { | |
3050b6df | 15 | int experimental; |
7211b9e7 | 16 | int value; |
ad0fb659 | 17 | char *strval; |
3050b6df | 18 | int manyfiles; |
7211b9e7 | 19 | |
3050b6df | 20 | if (r->settings.initialized++) |
7211b9e7 DS |
21 | return; |
22 | ||
23 | /* Defaults */ | |
3050b6df ÆAB |
24 | r->settings.index_version = -1; |
25 | r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP; | |
26 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT; | |
27 | ||
28 | /* Booleans config or default, cascades to other settings */ | |
29 | repo_cfg_bool(r, "feature.manyfiles", &manyfiles, 0); | |
30 | repo_cfg_bool(r, "feature.experimental", &experimental, 0); | |
7211b9e7 | 31 | |
3050b6df ÆAB |
32 | /* Defaults modified by feature.* */ |
33 | if (experimental) { | |
34 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING; | |
35 | } | |
36 | if (manyfiles) { | |
37 | r->settings.index_version = 4; | |
38 | r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE; | |
39 | } | |
40 | ||
41 | /* Boolean config or default, does not cascade (simple) */ | |
42 | repo_cfg_bool(r, "core.commitgraph", &r->settings.core_commit_graph, 1); | |
43 | repo_cfg_bool(r, "commitgraph.readchangedpaths", &r->settings.commit_graph_read_changed_paths, 1); | |
44 | repo_cfg_bool(r, "gc.writecommitgraph", &r->settings.gc_write_commit_graph, 1); | |
45 | repo_cfg_bool(r, "fetch.writecommitgraph", &r->settings.fetch_write_commit_graph, 0); | |
46 | repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1); | |
47 | repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1); | |
c21919f1 | 48 | repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0); |
3050b6df ÆAB |
49 | |
50 | /* | |
51 | * The GIT_TEST_MULTI_PACK_INDEX variable is special in that | |
52 | * either it *or* the config sets | |
53 | * r->settings.core_multi_pack_index if true. We don't take | |
54 | * the environment variable if it exists (even if false) over | |
55 | * any config, as in most other cases. | |
56 | */ | |
57 | if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0)) | |
58 | r->settings.core_multi_pack_index = 1; | |
7211b9e7 | 59 | |
3050b6df ÆAB |
60 | /* |
61 | * Non-boolean config | |
62 | */ | |
c11e9966 | 63 | if (!repo_config_get_int(r, "index.version", &value)) |
7211b9e7 | 64 | r->settings.index_version = value; |
ad0fb659 | 65 | |
3050b6df ÆAB |
66 | if (!repo_config_get_string(r, "core.untrackedcache", &strval)) { |
67 | int v = git_parse_maybe_bool(strval); | |
68 | ||
69 | /* | |
70 | * If it's set to "keep", or some other non-boolean | |
71 | * value then "v < 0". Then we do nothing and keep it | |
72 | * at the default of UNTRACKED_CACHE_KEEP. | |
73 | */ | |
74 | if (v >= 0) | |
75 | r->settings.core_untracked_cache = v ? | |
76 | UNTRACKED_CACHE_WRITE : UNTRACKED_CACHE_REMOVE; | |
ad0fb659 DS |
77 | free(strval); |
78 | } | |
79 | ||
aaf633c2 DS |
80 | if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) { |
81 | if (!strcasecmp(strval, "skipping")) | |
82 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING; | |
cbe566a0 JT |
83 | else if (!strcasecmp(strval, "noop")) |
84 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP; | |
aaf633c2 DS |
85 | } |
86 | ||
3964fc2a DS |
87 | /* |
88 | * This setting guards all index reads to require a full index | |
89 | * over a sparse index. After suitable guards are placed in the | |
90 | * codebase around uses of the index, this setting will be | |
91 | * removed. | |
92 | */ | |
93 | r->settings.command_requires_full_index = 1; | |
7211b9e7 | 94 | } |