]>
Commit | Line | Data |
---|---|---|
7211b9e7 DS |
1 | #include "cache.h" |
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 |
7 | static 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 | |
7211b9e7 DS |
14 | void prepare_repo_settings(struct repository *r) |
15 | { | |
3050b6df | 16 | int experimental; |
7211b9e7 | 17 | int value; |
ad0fb659 | 18 | char *strval; |
3050b6df | 19 | int manyfiles; |
7211b9e7 | 20 | |
44c7e62e LD |
21 | if (!r->gitdir) |
22 | BUG("Cannot add settings for uninitialized repository"); | |
23 | ||
3050b6df | 24 | if (r->settings.initialized++) |
7211b9e7 DS |
25 | return; |
26 | ||
27 | /* Defaults */ | |
3050b6df ÆAB |
28 | r->settings.index_version = -1; |
29 | r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP; | |
714edc62 | 30 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE; |
3050b6df ÆAB |
31 | |
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); | |
7211b9e7 | 35 | |
3050b6df ÆAB |
36 | /* Defaults modified by feature.* */ |
37 | if (experimental) { | |
38 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING; | |
39 | } | |
40 | if (manyfiles) { | |
41 | r->settings.index_version = 4; | |
42 | r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE; | |
43 | } | |
44 | ||
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); | |
c21919f1 | 52 | repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0); |
3050b6df ÆAB |
53 | |
54 | /* | |
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. | |
60 | */ | |
61 | if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0)) | |
62 | r->settings.core_multi_pack_index = 1; | |
7211b9e7 | 63 | |
3050b6df ÆAB |
64 | /* |
65 | * Non-boolean config | |
66 | */ | |
c11e9966 | 67 | if (!repo_config_get_int(r, "index.version", &value)) |
7211b9e7 | 68 | r->settings.index_version = value; |
ad0fb659 | 69 | |
3050b6df ÆAB |
70 | if (!repo_config_get_string(r, "core.untrackedcache", &strval)) { |
71 | int v = git_parse_maybe_bool(strval); | |
72 | ||
73 | /* | |
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. | |
77 | */ | |
78 | if (v >= 0) | |
79 | r->settings.core_untracked_cache = v ? | |
80 | UNTRACKED_CACHE_WRITE : UNTRACKED_CACHE_REMOVE; | |
ad0fb659 DS |
81 | free(strval); |
82 | } | |
83 | ||
aaf633c2 | 84 | if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) { |
714edc62 | 85 | int fetch_default = r->settings.fetch_negotiation_algorithm; |
aaf633c2 DS |
86 | if (!strcasecmp(strval, "skipping")) |
87 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING; | |
cbe566a0 JT |
88 | else if (!strcasecmp(strval, "noop")) |
89 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP; | |
714edc62 EN |
90 | else if (!strcasecmp(strval, "consecutive")) |
91 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE; | |
a68c5b9e | 92 | else if (!strcasecmp(strval, "default")) |
714edc62 | 93 | r->settings.fetch_negotiation_algorithm = fetch_default; |
a9a136c2 EN |
94 | else |
95 | die("unknown fetch negotiation algorithm '%s'", strval); | |
aaf633c2 DS |
96 | } |
97 | ||
3964fc2a DS |
98 | /* |
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. | |
103 | */ | |
104 | r->settings.command_requires_full_index = 1; | |
7211b9e7 | 105 | } |