Skip to content

Commit bc50d6c

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fde55b0 commit bc50d6c

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

commit-graph.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,7 @@ int write_commit_graph(struct object_directory *odb,
23482348
init_topo_level_slab(&topo_levels);
23492349
ctx->topo_levels = &topo_levels;
23502350

2351+
prepare_commit_graph(ctx->r);
23512352
if (ctx->r->objects->commit_graph) {
23522353
struct commit_graph *g = ctx->r->objects->commit_graph;
23532354

@@ -2361,7 +2362,6 @@ int write_commit_graph(struct object_directory *odb,
23612362
ctx->changed_paths = 1;
23622363
if (!(flags & COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS)) {
23632364
struct commit_graph *g;
2364-
prepare_commit_graph_one(ctx->r, ctx->odb);
23652365

23662366
g = ctx->r->objects->commit_graph;
23672367

@@ -2373,10 +2373,7 @@ int write_commit_graph(struct object_directory *odb,
23732373
}
23742374

23752375
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;
23802377

23812378
while (g) {
23822379
ctx->num_commit_graphs_before++;
@@ -2400,9 +2397,6 @@ int write_commit_graph(struct object_directory *odb,
24002397

24012398
ctx->approx_nr_objects = approximate_object_count();
24022399

2403-
if (ctx->append)
2404-
prepare_commit_graph_one(ctx->r, ctx->odb);
2405-
24062400
if (ctx->append && ctx->r->objects->commit_graph) {
24072401
struct commit_graph *g = ctx->r->objects->commit_graph;
24082402
for (i = 0; i < g->num_commits; i++) {

t/t5318-commit-graph.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ test_expect_success 'warn on improper hash version' '
446446
)
447447
'
448448

449-
test_expect_failure 'lower layers have overflow chunk' '
449+
test_expect_success 'lower layers have overflow chunk' '
450450
cd "$TRASH_DIRECTORY/full" &&
451451
UNIX_EPOCH_ZERO="@0 +0000" &&
452452
FUTURE_DATE="@2147483646 +0000" &&

0 commit comments

Comments
 (0)