for-each-repo: run subcommands on configured repos
[git/debian.git] / repo-settings.c
blob5bd2c2272669d79427b4708ffce8ab150239d102
1 #include "cache.h"
2 #include "config.h"
3 #include "repository.h"
4 #include "midx.h"
6 #define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
8 void prepare_repo_settings(struct repository *r)
10 int value;
11 char *strval;
13 if (r->settings.initialized)
14 return;
16 /* Defaults */
17 memset(&r->settings, -1, sizeof(r->settings));
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;
23 UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
24 UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
26 if (!repo_config_get_int(r, "index.version", &value))
27 r->settings.index_version = value;
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;
37 free(strval);
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;
47 if (!repo_config_get_bool(r, "pack.usesparse", &value))
48 r->settings.pack_use_sparse = value;
49 UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
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);
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);
61 if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value))
62 r->settings.fetch_write_commit_graph = value;
63 UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 0);
65 if (!repo_config_get_bool(r, "feature.experimental", &value) && value)
66 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
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);
74 UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT);