Skip to content

Commit 63020f1

Browse files
derrickstoleegitster
authored andcommitted
commit-graph: prefer default size_mult when given zero
In 50f26bd ("fetch: add fetch.writeCommitGraph config setting", 2019-09-02), the fetch builtin added the capability to write a commit-graph using the "--split" feature. This feature creates multiple commit-graph files, and those can merge based on a set of "split options" including a size multiple. The default size multiple is 2, which intends to provide a log_2 N depth of the commit-graph chain where N is the number of commits. However, I noticed during dogfooding that my commit-graph chains were becoming quite large when left only to builds by 'git fetch'. It turns out that in split_graph_merge_strategy(), we default the size_mult variable to 2 except we override it with the context's split_opts if they exist. In builtin/fetch.c, we create such a split_opts, but do not populate it with values. This problem is due to two failures: 1. It is unclear that we can add the flag COMMIT_GRAPH_WRITE_SPLIT with a NULL split_opts. 2. If we have a non-NULL split_opts, then we override the default values even if a zero value is given. Correct both of these issues. First, do not override size_mult when the options provide a zero value. Second, stop creating a split_opts in the fetch builtin. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 53a06cf commit 63020f1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

builtin/fetch.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,15 +1867,13 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
18671867
prepare_repo_settings(the_repository);
18681868
if (the_repository->settings.fetch_write_commit_graph) {
18691869
int commit_graph_flags = COMMIT_GRAPH_WRITE_SPLIT;
1870-
struct split_commit_graph_opts split_opts;
1871-
memset(&split_opts, 0, sizeof(struct split_commit_graph_opts));
18721870

18731871
if (progress)
18741872
commit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;
18751873

18761874
write_commit_graph_reachable(get_object_directory(),
18771875
commit_graph_flags,
1878-
&split_opts);
1876+
NULL);
18791877
}
18801878

18811879
close_object_store(the_repository->objects);

commit-graph.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,9 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
15451545

15461546
if (ctx->split_opts) {
15471547
max_commits = ctx->split_opts->max_commits;
1548-
size_mult = ctx->split_opts->size_multiple;
1548+
1549+
if (ctx->split_opts->size_multiple)
1550+
size_mult = ctx->split_opts->size_multiple;
15491551
}
15501552

15511553
g = ctx->r->objects->commit_graph;

0 commit comments

Comments
 (0)