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

[PATCH v3 4/8] odb: stop splitting alternate in `odb_add_to_alternates_file()`

From: Patrick Steinhardt <hidden>
Date: 2025-12-11 09:30:29
Subsystem: the rest · Maintainer: Linus Torvalds

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_alternate_recursively()`
instead.

Signed-off-by: Patrick Steinhardt <redacted>
---
 odb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/odb.c b/odb.c
index e314f86c3b..3112eab5d0 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_alternate_recursively(odb, dir, 0);
 	}
 	free(alts);
 }
-- 
2.52.0.270.g3f4935d65f.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help