]> git.ipfire.org Git - thirdparty/git.git/commit
odb: simplify calling `link_alt_odb_entry()`
authorPatrick Steinhardt <ps@pks.im>
Mon, 11 Aug 2025 13:46:45 +0000 (15:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Aug 2025 16:22:22 +0000 (09:22 -0700)
commit57363dfa0dce05aac735d5cfd626e6aac8cb706c
tree0dc9f9f2dea2686e83e183ebf5c2222b3df68eda
parenta59d44ff3f0f308f9577b05c858c063d2466b061
odb: simplify calling `link_alt_odb_entry()`

Callers of `link_alt_odb_entry()` are expected to pass in three
different paths:

  - The (potentially relative) path of the object directory that we're
    about to add.

  - The base that should be used to resolve a relative object directory
    path.

  - The resolved path to the object database's objects directory.

Juggling those three paths makes the calling convention somewhat hard to
grok at first.

As it turns out, the third parameter is redundant: we always pass in the
resolved path of the object database's primary source, and we already
pass in the database itself. So instead, we can resolve that path in the
function itself.

One downside of this is that one caller of `link_alt_odb_entry()` calls
this function in a loop, so we were able to resolve the directory a
single time, only. But ultimately, we only ever end up with a rather
limited number of alternates anyway, so the extra couple of cycles we
save feels more like a micro optimization.

Refactor the code accordingly.

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