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 <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
448a39e65dedb5f9a58d40e22ec7c0cc3be54173
1 file changed
+16
-6
commit-graph.c
+16
-6
@@ -614,19 +614,29 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
614
return graph_chain;
615
}
616
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)
622
{
619
- int read_generation_data;
623
+ int read_generation_data = 1;
624
+ struct commit_graph *p = g;
625
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
+ }
630
624
- read_generation_data = !!g->chunk_generation_data;
631
+ if (read_generation_data)
632
+ return 1;
633
634
while (g) {
627
- g->read_generation_data = read_generation_data;
635
+ g->read_generation_data = 0;
636
g = g->base_graph;
637
}
638
+
639
+ return 0;
640
}
641
642
struct commit_graph *read_commit_graph_one(struct repository *r,