2019-08-13 21:37:43 +03:00
|
|
|
#include "cache.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "repository.h"
|
2020-09-25 15:33:34 +03:00
|
|
|
#include "midx.h"
|
2019-08-13 21:37:43 +03:00
|
|
|
|
2019-08-13 21:37:45 +03:00
|
|
|
#define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
|
|
|
|
|
2019-08-13 21:37:43 +03:00
|
|
|
void prepare_repo_settings(struct repository *r)
|
|
|
|
{
|
|
|
|
int value;
|
2019-08-13 21:37:46 +03:00
|
|
|
char *strval;
|
2019-08-13 21:37:43 +03:00
|
|
|
|
|
|
|
if (r->settings.initialized)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Defaults */
|
|
|
|
memset(&r->settings, -1, sizeof(r->settings));
|
|
|
|
|
|
|
|
if (!repo_config_get_bool(r, "core.commitgraph", &value))
|
|
|
|
r->settings.core_commit_graph = value;
|
2020-09-09 18:23:10 +03:00
|
|
|
if (!repo_config_get_bool(r, "commitgraph.readchangedpaths", &value))
|
|
|
|
r->settings.commit_graph_read_changed_paths = value;
|
2019-08-13 21:37:43 +03:00
|
|
|
if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
|
|
|
|
r->settings.gc_write_commit_graph = value;
|
2019-08-13 21:37:45 +03:00
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
|
2020-09-09 18:23:10 +03:00
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.commit_graph_read_changed_paths, 1);
|
2019-08-13 21:37:45 +03:00
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
|
2019-08-13 21:37:43 +03:00
|
|
|
|
2019-10-23 23:38:57 +03:00
|
|
|
if (!repo_config_get_int(r, "index.version", &value))
|
2019-08-13 21:37:43 +03:00
|
|
|
r->settings.index_version = value;
|
2019-08-13 21:37:46 +03:00
|
|
|
if (!repo_config_get_maybe_bool(r, "core.untrackedcache", &value)) {
|
|
|
|
if (value == 0)
|
|
|
|
r->settings.core_untracked_cache = UNTRACKED_CACHE_REMOVE;
|
|
|
|
else
|
|
|
|
r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
|
|
|
|
} else if (!repo_config_get_string(r, "core.untrackedcache", &strval)) {
|
|
|
|
if (!strcasecmp(strval, "keep"))
|
|
|
|
r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
|
|
|
|
|
|
|
|
free(strval);
|
|
|
|
}
|
|
|
|
|
2019-08-13 21:37:48 +03:00
|
|
|
if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
|
|
|
|
if (!strcasecmp(strval, "skipping"))
|
|
|
|
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
|
2020-08-18 07:01:31 +03:00
|
|
|
else if (!strcasecmp(strval, "noop"))
|
|
|
|
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
|
2019-08-13 21:37:48 +03:00
|
|
|
else
|
|
|
|
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
|
|
|
|
}
|
|
|
|
|
2019-08-13 21:37:43 +03:00
|
|
|
if (!repo_config_get_bool(r, "pack.usesparse", &value))
|
|
|
|
r->settings.pack_use_sparse = value;
|
2020-03-20 15:38:09 +03:00
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
|
|
|
|
|
2020-09-25 15:33:34 +03:00
|
|
|
value = git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0);
|
|
|
|
if (value || !repo_config_get_bool(r, "core.multipackindex", &value))
|
|
|
|
r->settings.core_multi_pack_index = value;
|
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.core_multi_pack_index, 1);
|
|
|
|
|
2019-08-13 21:37:47 +03:00
|
|
|
if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
|
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
|
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
|
|
|
|
}
|
experimental: default to fetch.writeCommitGraph=false
The fetch.writeCommitGraph feature makes fetches write out a commit
graph file for the newly downloaded pack on fetch. This improves the
performance of various commands that would perform a revision walk and
eventually ought to be the default for everyone. To prepare for that
future, it's enabled by default for users that set
feature.experimental=true to experience such future defaults.
Alas, for --unshallow fetches from a shallow clone it runs into a
snag: by the time Git has fetched the new objects and is writing a
commit graph, it has performed a revision walk and r->parsed_objects
contains information about the shallow boundary from *before* the
fetch. The commit graph writing code is careful to avoid writing a
commit graph file in shallow repositories, but the new state is not
shallow, and the result is that from that point on, commands like "git
log" make use of a newly written commit graph file representing a
fictional history with the old shallow boundary.
We could fix this by making the commit graph writing code more careful
to avoid writing a commit graph that could have used any grafts or
shallow state, but it is possible that there are other pieces of
mutated state that fetch's commit graph writing code may be relying
on. So disable it in the feature.experimental configuration.
Google developers have been running in this configuration (by setting
fetch.writeCommitGraph=false in the system config) to work around this
bug since it was discovered in April. Once the fix lands, we'll
enable fetch.writeCommitGraph=true again to give it some early testing
before rolling out to a wider audience.
In other words:
- this patch only affects behavior with feature.experimental=true
- it makes feature.experimental match the configuration Google has
been using for the last few months, meaning it would leave users in
a better tested state than without it
- this should improve testing for other features guarded by
feature.experimental, by making feature.experimental safer to use
Reported-by: Jay Conrod <jayconrod@google.com>
Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-07-07 09:20:39 +03:00
|
|
|
|
2019-09-03 05:22:02 +03:00
|
|
|
if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value))
|
|
|
|
r->settings.fetch_write_commit_graph = value;
|
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 0);
|
2019-08-13 21:37:46 +03:00
|
|
|
|
experimental: default to fetch.writeCommitGraph=false
The fetch.writeCommitGraph feature makes fetches write out a commit
graph file for the newly downloaded pack on fetch. This improves the
performance of various commands that would perform a revision walk and
eventually ought to be the default for everyone. To prepare for that
future, it's enabled by default for users that set
feature.experimental=true to experience such future defaults.
Alas, for --unshallow fetches from a shallow clone it runs into a
snag: by the time Git has fetched the new objects and is writing a
commit graph, it has performed a revision walk and r->parsed_objects
contains information about the shallow boundary from *before* the
fetch. The commit graph writing code is careful to avoid writing a
commit graph file in shallow repositories, but the new state is not
shallow, and the result is that from that point on, commands like "git
log" make use of a newly written commit graph file representing a
fictional history with the old shallow boundary.
We could fix this by making the commit graph writing code more careful
to avoid writing a commit graph that could have used any grafts or
shallow state, but it is possible that there are other pieces of
mutated state that fetch's commit graph writing code may be relying
on. So disable it in the feature.experimental configuration.
Google developers have been running in this configuration (by setting
fetch.writeCommitGraph=false in the system config) to work around this
bug since it was discovered in April. Once the fix lands, we'll
enable fetch.writeCommitGraph=true again to give it some early testing
before rolling out to a wider audience.
In other words:
- this patch only affects behavior with feature.experimental=true
- it makes feature.experimental match the configuration Google has
been using for the last few months, meaning it would leave users in
a better tested state than without it
- this should improve testing for other features guarded by
feature.experimental, by making feature.experimental safer to use
Reported-by: Jay Conrod <jayconrod@google.com>
Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-07-07 09:20:39 +03:00
|
|
|
if (!repo_config_get_bool(r, "feature.experimental", &value) && value)
|
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
|
|
|
|
|
2019-08-13 21:37:46 +03:00
|
|
|
/* Hack for test programs like test-dump-untracked-cache */
|
|
|
|
if (ignore_untracked_cache_config)
|
|
|
|
r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
|
|
|
|
else
|
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_KEEP);
|
2019-08-13 21:37:48 +03:00
|
|
|
|
|
|
|
UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT);
|
2019-08-13 21:37:43 +03:00
|
|
|
}
|