Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2023-03-20 14:26:52 +0300
committerJunio C Hamano <gitster@pobox.com>2023-03-20 22:17:33 +0300
commitc08645b353514fe14dbd62cf52afd49d0e88146b (patch)
tree84a5f63ae98268bb48424f2d2274329a97e34a5f /commit-graph.c
parent2ee11f7261cc7ac386ec683f774472b0309dcc82 (diff)
commit-graph: introduce `ensure_generations_valid()`
Use the just-introduced compute_reachable_generation_numbers_1() to implement a function which dynamically computes topological levels (or corrected commit dates) for out-of-graph commits. This will be useful for the ahead-behind algorithm we are about to introduce, which needs accurate topological levels on _all_ commits reachable from the tips in order to avoid over-counting. Co-authored-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 63a56483cf..172e679db1 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1604,6 +1604,35 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)
stop_progress(&ctx->progress);
}
+static void set_generation_in_graph_data(struct commit *c, timestamp_t t,
+ void *data)
+{
+ commit_graph_data_at(c)->generation = t;
+}
+
+/*
+ * After this method, all commits reachable from those in the given
+ * list will have non-zero, non-infinite generation numbers.
+ */
+void ensure_generations_valid(struct repository *r,
+ struct commit **commits, size_t nr)
+{
+ int generation_version = get_configured_generation_version(r);
+ struct packed_commit_list list = {
+ .list = commits,
+ .alloc = nr,
+ .nr = nr,
+ };
+ struct compute_generation_info info = {
+ .r = r,
+ .commits = &list,
+ .get_generation = get_generation_from_graph_data,
+ .set_generation = set_generation_in_graph_data,
+ };
+
+ compute_reachable_generation_numbers(&info, generation_version);
+}
+
static void trace2_bloom_filter_write_statistics(struct write_commit_graph_context *ctx)
{
trace2_data_intmax("commit-graph", ctx->r, "filter-computed",