aboutsummaryrefslogtreecommitdiffstats
path: root/commit-graph.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-02-02 03:01:20 +0000
committerJunio C Hamano <gitster@pobox.com>2021-02-01 21:03:36 -0800
commit448a39e65dedb5f9a58d40e22ec7c0cc3be54173 (patch)
treede4bf17e7c11119152150af6c45f7244f3903d70 /commit-graph.c
parent90cb1c47c7cbf6cdd5152c1371a2732af59911a4 (diff)
downloadgit-448a39e65dedb5f9a58d40e22ec7c0cc3be54173.tar.gz
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>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/commit-graph.c b/commit-graph.c
index edbb3a0f2c..b3f7c3bbcb 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -614,19 +614,29 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
return graph_chain;
}
-static void validate_mixed_generation_chain(struct commit_graph *g)
+/*
+ * returns 1 if and only if all graphs in the chain have
+ * corrected commit dates stored in the generation_data chunk.
+ */
+static int validate_mixed_generation_chain(struct commit_graph *g)
{
- int read_generation_data;
+ int read_generation_data = 1;
+ struct commit_graph *p = g;
- if (!g)
- return;
+ while (read_generation_data && p) {
+ read_generation_data = p->read_generation_data;
+ p = p->base_graph;
+ }
- read_generation_data = !!g->chunk_generation_data;
+ if (read_generation_data)
+ return 1;
while (g) {
- g->read_generation_data = read_generation_data;
+ g->read_generation_data = 0;
g = g->base_graph;
}
+
+ return 0;
}
struct commit_graph *read_commit_graph_one(struct repository *r,