Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2022-07-15 00:43:06 +0300
committerJunio C Hamano <gitster@pobox.com>2022-07-15 01:42:17 +0300
commita92d8523cef66d46e24cd5ef2f01ef97dc4ab239 (patch)
tree22e9f374000184d9eb40af63d1bbab896c5d59e0 /repo-settings.c
parent8168d5e9c23ed44ae3d604f392320d66556453c9 (diff)
commit-graph: pass repo_settings instead of repository
The parse_commit_graph() function takes a 'struct repository *' pointer, but it only ever accesses config settings (either directly or through the .settings field of the repo struct). Move all relevant config settings into the repo_settings struct, and update parse_commit_graph() and its existing callers so that it takes 'struct repo_settings *' instead. Callers of parse_commit_graph() will now need to call prepare_repo_settings() themselves, or initialize a 'struct repo_settings' directly. Prior to ab14d0676c (commit-graph: pass a 'struct repository *' in more places, 2020-09-09), parsing a commit-graph was a pure function depending only on the contents of the commit-graph itself. Commit ab14d0676c introduced a dependency on a `struct repository` pointer, and later commits such as b66d84756f (commit-graph: respect 'commitGraph.readChangedPaths', 2020-09-09) added dependencies on config settings, which were accessed through the `settings` field of the repository pointer. This field was initialized via a call to `prepare_repo_settings()`. Additionally, this fixes an issue in fuzz-commit-graph: In 44c7e62 (2021-12-06, repo-settings:prepare_repo_settings only in git repos), prepare_repo_settings was changed to issue a BUG() if it is called by a process whose CWD is not a Git repository. The combination of commits mentioned above broke fuzz-commit-graph, which attempts to parse arbitrary fuzzing-engine-provided bytes as a commit graph file. Prior to this change, parse_commit_graph() called prepare_repo_settings(), but since we run the fuzz tests without a valid repository, we are hitting the BUG() from 44c7e62 for every test case. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repo-settings.c')
-rw-r--r--repo-settings.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/repo-settings.c b/repo-settings.c
index 2dfcb2b654..43bc881bfc 100644
--- a/repo-settings.c
+++ b/repo-settings.c
@@ -11,6 +11,13 @@ static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
*dest = def;
}
+static void repo_cfg_int(struct repository *r, const char *key, int *dest,
+ int def)
+{
+ if (repo_config_get_int(r, key, dest))
+ *dest = def;
+}
+
void prepare_repo_settings(struct repository *r)
{
int experimental;
@@ -42,11 +49,14 @@ void prepare_repo_settings(struct repository *r)
r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
}
- /* Boolean config or default, does not cascade (simple) */
+ /* Commit graph config or default, does not cascade (simple) */
repo_cfg_bool(r, "core.commitgraph", &r->settings.core_commit_graph, 1);
+ repo_cfg_int(r, "commitgraph.generationversion", &r->settings.commit_graph_generation_version, 2);
repo_cfg_bool(r, "commitgraph.readchangedpaths", &r->settings.commit_graph_read_changed_paths, 1);
repo_cfg_bool(r, "gc.writecommitgraph", &r->settings.gc_write_commit_graph, 1);
repo_cfg_bool(r, "fetch.writecommitgraph", &r->settings.fetch_write_commit_graph, 0);
+
+ /* Boolean config or default, does not cascade (simple) */
repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1);
repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);