builtin/commit-graph.c: introduce split strategy 'no-merge'
In the previous commit, we laid the groundwork for supporting different
splitting strategies. In this commit, we introduce the first splitting
strategy: 'no-merge'.
Passing '--split=no-merge' is useful for callers which wish to write a
new incremental commit-graph, but do not want to spend effort condensing
the incremental chain [1]. Previously, this was possible by passing
'--size-multiple=0', but this no longer the case following 63020f175f
(commit-graph: prefer default size_mult when given zero, 2020-01-02).
When '--split=no-merge' is given, the commit-graph machinery will never
condense an existing chain, and it will always write a new incremental.
[1]: This might occur when, for example, a server administrator running
some program after each push may want to ensure that each job runs
proportional in time to the size of the push, and does not "jump" when
the commit-graph machinery decides to trigger a merge.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
4f027355f6
commit
fdbde82fe5
@ -1529,6 +1529,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
|
||||
{
|
||||
struct commit_graph *g;
|
||||
uint32_t num_commits;
|
||||
enum commit_graph_split_flags flags = COMMIT_GRAPH_SPLIT_UNSPECIFIED;
|
||||
uint32_t i;
|
||||
|
||||
int max_commits = 0;
|
||||
@ -1539,21 +1540,25 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
|
||||
|
||||
if (ctx->split_opts->size_multiple)
|
||||
size_mult = ctx->split_opts->size_multiple;
|
||||
|
||||
flags = ctx->split_opts->flags;
|
||||
}
|
||||
|
||||
g = ctx->r->objects->commit_graph;
|
||||
num_commits = ctx->commits.nr;
|
||||
ctx->num_commit_graphs_after = ctx->num_commit_graphs_before + 1;
|
||||
|
||||
while (g && (g->num_commits <= size_mult * num_commits ||
|
||||
(max_commits && num_commits > max_commits))) {
|
||||
if (g->odb != ctx->odb)
|
||||
break;
|
||||
if (flags != COMMIT_GRAPH_SPLIT_MERGE_PROHIBITED) {
|
||||
while (g && (g->num_commits <= size_mult * num_commits ||
|
||||
(max_commits && num_commits > max_commits))) {
|
||||
if (g->odb != ctx->odb)
|
||||
break;
|
||||
|
||||
num_commits += g->num_commits;
|
||||
g = g->base_graph;
|
||||
num_commits += g->num_commits;
|
||||
g = g->base_graph;
|
||||
|
||||
ctx->num_commit_graphs_after--;
|
||||
ctx->num_commit_graphs_after--;
|
||||
}
|
||||
}
|
||||
|
||||
ctx->new_base_graph = g;
|
||||
|
||||
Reference in New Issue
Block a user