]> Kevux Git Server - rit/commit
commit-graph: return the prepared commit graph from `prepare_commit_graph()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 4 Sep 2025 12:49:57 +0000 (14:49 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Sep 2025 23:16:22 +0000 (16:16 -0700)
commit199d452758605a3ff15ac7d900653b4de7455e24
tree30cd16db11f4dee4fdb1b1484bec7d09e9cf5a1b
parent307e30792b3fb256f58816c4ca67d647eb76c788
commit-graph: return the prepared commit graph from `prepare_commit_graph()`

When making use of commit graphs, one needs to first prepare them by
calling `prepare_commit_graph()`. Once that function was called and the
commit graph was prepared successfully, the caller is now expected to
access the graph directly via `struct object_database::commit_graph`.

In a subsequent change, we're going to move the commit graph pointer
from `struct object_database` into `struct odb_source`. With this
change, semantics will change so that we use the commit graph of the
first source that has one. Consequently, all callers that currently
deference the `commit_graph` pointer would now have to loop around the
list of sources to find the commit graph.

This would become quite unwieldy. So instead of shifting the burden onto
such callers, adapt `prepare_commit_graph()` to return the prepared
commit graph, if any. Like this, callers are expected to call that
function and then use the returned commit graph.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c