]>
Commit | Line | Data |
---|---|---|
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 |
8 | void 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; | |
b66d8475 TB |
21 | if (!repo_config_get_bool(r, "commitgraph.readchangedpaths", &value)) |
22 | r->settings.commit_graph_read_changed_paths = value; | |
7211b9e7 DS |
23 | if (!repo_config_get_bool(r, "gc.writecommitgraph", &value)) |
24 | r->settings.gc_write_commit_graph = value; | |
31b1de6a | 25 | UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1); |
b66d8475 | 26 | UPDATE_DEFAULT_BOOL(r->settings.commit_graph_read_changed_paths, 1); |
31b1de6a | 27 | UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1); |
7211b9e7 | 28 | |
c11e9966 | 29 | if (!repo_config_get_int(r, "index.version", &value)) |
7211b9e7 | 30 | r->settings.index_version = value; |
ad0fb659 DS |
31 | if (!repo_config_get_maybe_bool(r, "core.untrackedcache", &value)) { |
32 | if (value == 0) | |
33 | r->settings.core_untracked_cache = UNTRACKED_CACHE_REMOVE; | |
34 | else | |
35 | r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE; | |
36 | } else if (!repo_config_get_string(r, "core.untrackedcache", &strval)) { | |
37 | if (!strcasecmp(strval, "keep")) | |
38 | r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP; | |
39 | ||
40 | free(strval); | |
41 | } | |
42 | ||
aaf633c2 DS |
43 | if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) { |
44 | if (!strcasecmp(strval, "skipping")) | |
45 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING; | |
cbe566a0 JT |
46 | else if (!strcasecmp(strval, "noop")) |
47 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP; | |
aaf633c2 DS |
48 | else |
49 | r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT; | |
50 | } | |
51 | ||
7211b9e7 DS |
52 | if (!repo_config_get_bool(r, "pack.usesparse", &value)) |
53 | r->settings.pack_use_sparse = value; | |
de3a8641 DS |
54 | UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1); |
55 | ||
18e449f8 DS |
56 | value = git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0); |
57 | if (value || !repo_config_get_bool(r, "core.multipackindex", &value)) | |
58 | r->settings.core_multi_pack_index = value; | |
59 | UPDATE_DEFAULT_BOOL(r->settings.core_multi_pack_index, 1); | |
60 | ||
c6cc4c5a DS |
61 | if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) { |
62 | UPDATE_DEFAULT_BOOL(r->settings.index_version, 4); | |
63 | UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE); | |
64 | } | |
b5651a20 | 65 | |
50f26bd0 DS |
66 | if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value)) |
67 | r->settings.fetch_write_commit_graph = value; | |
50f26bd0 | 68 | UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 0); |
ad0fb659 | 69 | |
b5651a20 JN |
70 | if (!repo_config_get_bool(r, "feature.experimental", &value) && value) |
71 | UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING); | |
72 | ||
ad0fb659 DS |
73 | /* Hack for test programs like test-dump-untracked-cache */ |
74 | if (ignore_untracked_cache_config) | |
75 | r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP; | |
76 | else | |
77 | UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_KEEP); | |
aaf633c2 DS |
78 | |
79 | UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT); | |
7211b9e7 | 80 | } |