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