Thread (41 messages) 41 messages, 3 authors, 2025-12-11

Re: [PATCH v2 4/8] odb: adapt `odb_add_to_alternates_file()` to call `odb_add_source()`

From: Patrick Steinhardt <hidden>
Date: 2025-12-11 09:29:50

On Thu, Dec 11, 2025 at 08:21:43AM +0100, SZEDER Gábor wrote:
On Wed, Dec 10, 2025 at 04:32:37PM +0100, Patrick Steinhardt wrote:
quoted
When calling `odb_add_to_alternates_file()` we know to add the newly
added source to the object database in case we have already loaded
alternates. This is done so that we can make its objects accessible
immediately without having to fully reload all alternates.

The way we do this though is to call `link_alt_odb_entries()`, which
adds _multiple_ sources to the object database source in case we have
newline-separated entries. This behaviour is not documented in the
function documentation of `odb_add_to_alternates_file()`, and all
callers only ever pass a single directory to it. It's thus entirely
surprising and a conceptual mismatch.

Fix this issue by directly calling `odb_add_source()` instead.
OK, but:
quoted
diff --git a/odb.c b/odb.c
index e314f86c3b..d97e50fb61 100644
--- a/odb.c
+++ b/odb.c
@@ -338,7 +338,7 @@ void odb_add_to_alternates_file(struct object_database *odb,
 		if (commit_lock_file(&lock))
 			die_errno(_("unable to move new alternates file into place"));
 		if (odb->loaded_alternates)
-			link_alt_odb_entries(odb, dir, '\n', NULL, 0);
+			odb_add_source(odb, dir, 0);
      CC odb.o
  odb.c: In function ‘odb_add_to_alternates_file’:
  odb.c:341:25: error: implicit declaration of function ‘odb_add_source’; did you mean ‘odb_find_source’? [-Werror=implicit-function-declaration]
    341 |                         odb_add_source(odb, dir, 0);
        |                         ^~~~~~~~~~~~~~
        |                         odb_find_source
  cc1: all warnings being treated as errors
  make: *** [Makefile:2864: odb.o] Error 1
Hrmpf, I only fixed this callsite in a later commit indeed.
Note, that several commit messages also refer to this non-existing
function from the previous round.
True. Will fix both of these issues, thanks!

Patrick
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help