commit-graph: prepare commit graph
Before checking if the repository has a commit-graph loaded, be sure to run prepare_commit_graph(). This is necessary because otherwise the topo_levels slab is not initialized. As we compute topo_levels for the new commits, we iterate further into the lower layers since the first visit to each commit looks as though the topo_level is not populated. By properly initializing the topo_slab, we fix the previously broken case of a split commit graph where a base layer has the generation_data_overflow chunk. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Feb 2, 2021 at 03:01 UTC
bc50d6c91f4002b4197a9f5ea5dfdc3c9f105a1c
2 files changed
+3
-9
commit-graph.c
+2
-8
@@ -2348,6 +2348,7 @@ int write_commit_graph(struct object_directory *odb,
2348
init_topo_level_slab(&topo_levels);
2349
ctx->topo_levels = &topo_levels;
2350
2351
+ prepare_commit_graph(ctx->r);
2352
if (ctx->r->objects->commit_graph) {
2353
struct commit_graph *g = ctx->r->objects->commit_graph;
2354
@@ -2361,7 +2362,6 @@ int write_commit_graph(struct object_directory *odb,
2362
ctx->changed_paths = 1;
2363
if (!(flags & COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS)) {
2364
struct commit_graph *g;
2364
- prepare_commit_graph_one(ctx->r, ctx->odb);
2365
2366
g = ctx->r->objects->commit_graph;
2367
@@ -2373,10 +2373,7 @@ int write_commit_graph(struct object_directory *odb,
2373
}
2374
2375
if (ctx->split) {
2376
- struct commit_graph *g;
2377
- prepare_commit_graph(ctx->r);
2378
-
2379
- g = ctx->r->objects->commit_graph;
2376
+ struct commit_graph *g = ctx->r->objects->commit_graph;
2377
2378
while (g) {
2379
ctx->num_commit_graphs_before++;
@@ -2400,9 +2397,6 @@ int write_commit_graph(struct object_directory *odb,
2397
2398
ctx->approx_nr_objects = approximate_object_count();
2399
2403
- if (ctx->append)
2404
- prepare_commit_graph_one(ctx->r, ctx->odb);
2405
-
2400
if (ctx->append && ctx->r->objects->commit_graph) {
2401
struct commit_graph *g = ctx->r->objects->commit_graph;
2402
for (i = 0; i < g->num_commits; i++) {
t/t5318-commit-graph.sh
+1
-1
@@ -446,7 +446,7 @@ test_expect_success 'warn on improper hash version' '
446
)
447
'
448
449
-test_expect_failure 'lower layers have overflow chunk' '
449
+test_expect_success 'lower layers have overflow chunk' '
450
cd "$TRASH_DIRECTORY/full" &&
451
UNIX_EPOCH_ZERO="@0 +0000" &&
452
FUTURE_DATE="@2147483646 +0000" &&