]> git.ipfire.org Git - thirdparty/git.git/commit
commit-graph: refactor compute_topological_levels()
authorDerrick Stolee <derrickstolee@github.com>
Mon, 20 Mar 2023 11:26:49 +0000 (11:26 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Mar 2023 19:17:33 +0000 (12:17 -0700)
commit368d19b0b7fa780d84918cf4ed4a31a410ed865d
treeed04df89b69846650860303fea3d7acc191950dc
parentb2c51b75902acfbb8ab8ac9aadc919bf5a447c1b
commit-graph: refactor compute_topological_levels()

This patch extracts the common code used to compute topological levels
and corrected committer dates into a common routine,
compute_reachable_generation_numbers(). For ease of reading, it only
modifies compute_topological_levels() to use this new routine, leaving
compute_generation_numbers() to be modified in the next change.

This new routine dispatches to call the necessary functions to get and
set the generation number for a given commit through a vtable (the
compute_generation_info struct).

Computing the generation number itself is done in
compute_generation_from_max(), which dispatches its implementation based
on the generation version requested, or issuing a BUG() for unrecognized
generation versions. This does not use a vtable because the logic
depends only on the generation number version, not where the data is
being loaded from or being stored to. This is a subtle point that will
make more sense in a future change that modifies the in-memory
generation values instead of just preparing values for writing to a
commit-graph file.

This change looks like it adds a lot of new code. However, two upcoming
changes will be quite small due to the work being done in this change.

Co-authored-by: Taylor Blau <me@ttaylorr.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>
commit-graph.c