Skip to content

Commit 448a39e

Browse files
derrickstoleegitster
authored andcommitted
commit-graph: validate layers for generation data
We need to be extra careful that we don't use corrected commit dates from any layer of a commit-graph chain if there is a single commit-graph file that is missing the generation_data chunk. Update validate_mixed_generation_chain() to correctly update each layer to ignore the generation_data chunk in this case. It now also returns 1 if all layers have a generation_data chunk. This return value will be used in the next change. Signed-off-by: Derrick Stolee <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 90cb1c4 commit 448a39e

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

commit-graph.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,19 +614,29 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
614614
return graph_chain;
615615
}
616616

617-
static void validate_mixed_generation_chain(struct commit_graph *g)
617+
/*
618+
* returns 1 if and only if all graphs in the chain have
619+
* corrected commit dates stored in the generation_data chunk.
620+
*/
621+
static int validate_mixed_generation_chain(struct commit_graph *g)
618622
{
619-
int read_generation_data;
623+
int read_generation_data = 1;
624+
struct commit_graph *p = g;
620625

621-
if (!g)
622-
return;
626+
while (read_generation_data && p) {
627+
read_generation_data = p->read_generation_data;
628+
p = p->base_graph;
629+
}
623630

624-
read_generation_data = !!g->chunk_generation_data;
631+
if (read_generation_data)
632+
return 1;
625633

626634
while (g) {
627-
g->read_generation_data = read_generation_data;
635+
g->read_generation_data = 0;
628636
g = g->base_graph;
629637
}
638+
639+
return 0;
630640
}
631641

632642
struct commit_graph *read_commit_graph_one(struct repository *r,

0 commit comments

Comments
 (0)