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