]> git.feebdaed.xyz Git - 0xmirror/git.git/commit
odb: remove mutual recursion when parsing alternates
authorPatrick Steinhardt <ps@pks.im>
Thu, 11 Dec 2025 09:30:14 +0000 (10:30 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Dec 2025 09:39:36 +0000 (18:39 +0900)
commit430e0e0f2e75673206321f6f4942c0bc7856c8b7
tree85227bf68a0415f327c55724ed29759cc57e60d3
parentdccfb39cdb68e47a4c7103b3c465cde91c5f9f56
odb: remove mutual recursion when parsing alternates

When adding an alternative object database source we not only have to
consider the added source itself, but we also have to add _its_ sources
to our database. We implement this via mutual recursion:

  1. We first call `link_alt_odb_entries()`.

  2. `link_alt_odb_entries()` calls `parse_alternates()`.

  3. We then add each alternate via `odb_add_alternate_recursively()`.

  4. `odb_add_alternate_recursively()` calls `link_alt_odb_entries()`
     again.

This flow is somewhat hard to follow, but more importantly it means that
parsing of alternates is somewhat tied to the recursive behaviour.

Refactor the function to remove the mutual recursion between adding
sources and parsing alternates. The parsing step thus becomes completely
oblivious to the fact that there is recursive behaviour going on at all.
The recursion is handled by `odb_add_alternate_recursively()` instead,
which now recurses with itself.

This refactoring allows us to move parsing of alternates into object
database sources in a subsequent step.

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