3 #include "repository.h"
5 #define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
7 void prepare_repo_settings(struct repository
*r
)
12 if (r
->settings
.initialized
)
16 memset(&r
->settings
, -1, sizeof(r
->settings
));
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
;
22 UPDATE_DEFAULT_BOOL(r
->settings
.core_commit_graph
, 1);
23 UPDATE_DEFAULT_BOOL(r
->settings
.gc_write_commit_graph
, 1);
25 if (!repo_config_get_int(r
, "index.version", &value
))
26 r
->settings
.index_version
= value
;
27 if (!repo_config_get_maybe_bool(r
, "core.untrackedcache", &value
)) {
29 r
->settings
.core_untracked_cache
= UNTRACKED_CACHE_REMOVE
;
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
;
39 if (!repo_config_get_string(r
, "fetch.negotiationalgorithm", &strval
)) {
40 if (!strcasecmp(strval
, "skipping"))
41 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_SKIPPING
;
43 r
->settings
.fetch_negotiation_algorithm
= FETCH_NEGOTIATION_DEFAULT
;
46 if (!repo_config_get_bool(r
, "pack.usesparse", &value
))
47 r
->settings
.pack_use_sparse
= value
;
48 UPDATE_DEFAULT_BOOL(r
->settings
.pack_use_sparse
, 1);
50 if (!repo_config_get_bool(r
, "feature.manyfiles", &value
) && value
) {
51 UPDATE_DEFAULT_BOOL(r
->settings
.index_version
, 4);
52 UPDATE_DEFAULT_BOOL(r
->settings
.core_untracked_cache
, UNTRACKED_CACHE_WRITE
);
55 if (!repo_config_get_bool(r
, "fetch.writecommitgraph", &value
))
56 r
->settings
.fetch_write_commit_graph
= value
;
57 UPDATE_DEFAULT_BOOL(r
->settings
.fetch_write_commit_graph
, 0);
59 if (!repo_config_get_bool(r
, "feature.experimental", &value
) && value
)
60 UPDATE_DEFAULT_BOOL(r
->settings
.fetch_negotiation_algorithm
, FETCH_NEGOTIATION_SKIPPING
);
62 /* Hack for test programs like test-dump-untracked-cache */
63 if (ignore_untracked_cache_config
)
64 r
->settings
.core_untracked_cache
= UNTRACKED_CACHE_KEEP
;
66 UPDATE_DEFAULT_BOOL(r
->settings
.core_untracked_cache
, UNTRACKED_CACHE_KEEP
);
68 UPDATE_DEFAULT_BOOL(r
->settings
.fetch_negotiation_algorithm
, FETCH_NEGOTIATION_DEFAULT
);