]> git.ipfire.org Git - thirdparty/git.git/blame - repo-settings.c
midx: enable core.multiPackIndex by default
[thirdparty/git.git] / repo-settings.c
CommitLineData
7211b9e7
DS
1#include "cache.h"
2#include "config.h"
3#include "repository.h"
18e449f8 4#include "midx.h"
7211b9e7 5
31b1de6a
DS
6#define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
7
7211b9e7
DS
8void prepare_repo_settings(struct repository *r)
9{
10 int value;
ad0fb659 11 char *strval;
7211b9e7
DS
12
13 if (r->settings.initialized)
14 return;
15
16 /* Defaults */
17 memset(&r->settings, -1, sizeof(r->settings));
18
19 if (!repo_config_get_bool(r, "core.commitgraph", &value))
20 r->settings.core_commit_graph = value;
21 if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
22 r->settings.gc_write_commit_graph = value;
31b1de6a
DS
23 UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
24 UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
7211b9e7 25
c11e9966 26 if (!repo_config_get_int(r, "index.version", &value))
7211b9e7 27 r->settings.index_version = value;
ad0fb659
DS
28 if (!repo_config_get_maybe_bool(r, "core.untrackedcache", &value)) {
29 if (value == 0)
30 r->settings.core_untracked_cache = UNTRACKED_CACHE_REMOVE;
31 else
32 r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
33 } else if (!repo_config_get_string(r, "core.untrackedcache", &strval)) {
34 if (!strcasecmp(strval, "keep"))
35 r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
36
37 free(strval);
38 }
39
aaf633c2
DS
40 if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
41 if (!strcasecmp(strval, "skipping"))
42 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
43 else
44 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
45 }
46
7211b9e7
DS
47 if (!repo_config_get_bool(r, "pack.usesparse", &value))
48 r->settings.pack_use_sparse = value;
de3a8641
DS
49 UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
50
18e449f8
DS
51 value = git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0);
52 if (value || !repo_config_get_bool(r, "core.multipackindex", &value))
53 r->settings.core_multi_pack_index = value;
54 UPDATE_DEFAULT_BOOL(r->settings.core_multi_pack_index, 1);
55
c6cc4c5a
DS
56 if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
57 UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
58 UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
59 }
b5651a20 60
50f26bd0
DS
61 if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value))
62 r->settings.fetch_write_commit_graph = value;
50f26bd0 63 UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 0);
ad0fb659 64
b5651a20
JN
65 if (!repo_config_get_bool(r, "feature.experimental", &value) && value)
66 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
67
ad0fb659
DS
68 /* Hack for test programs like test-dump-untracked-cache */
69 if (ignore_untracked_cache_config)
70 r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
71 else
72 UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_KEEP);
aaf633c2
DS
73
74 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT);
7211b9e7 75}