]> git.ipfire.org Git - thirdparty/git.git/blob - repo-settings.c
push: do not turn --delete '' into a matching push
[thirdparty/git.git] / repo-settings.c
1 #include "cache.h"
2 #include "config.h"
3 #include "repository.h"
4
5 #define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
6
7 void prepare_repo_settings(struct repository *r)
8 {
9 int value;
10 char *strval;
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, "commitgraph.readchangedpaths", &value))
21 r->settings.commit_graph_read_changed_paths = value;
22 if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
23 r->settings.gc_write_commit_graph = value;
24 UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
25 UPDATE_DEFAULT_BOOL(r->settings.commit_graph_read_changed_paths, 1);
26 UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
27
28 if (!repo_config_get_int(r, "index.version", &value))
29 r->settings.index_version = value;
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
42 if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
43 if (!strcasecmp(strval, "skipping"))
44 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
45 else if (!strcasecmp(strval, "noop"))
46 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
47 else
48 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
49 }
50
51 if (!repo_config_get_bool(r, "pack.usesparse", &value))
52 r->settings.pack_use_sparse = value;
53 UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
54
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 }
59
60 if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value))
61 r->settings.fetch_write_commit_graph = value;
62 UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 0);
63
64 if (!repo_config_get_bool(r, "feature.experimental", &value) && value)
65 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
66
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);
72
73 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT);
74 }