On Wed, Aug 06, 2025 at 06:40:23PM +0200, Toon Claes wrote: > Patrick Steinhardt <ps@xxxxxx> writes: > > diff --git a/odb.c b/odb.c > > index 61104b7cb8..7793816f81 100644 > > --- a/odb.c > > +++ b/odb.c > > @@ -316,17 +315,23 @@ void odb_add_to_alternates_file(struct object_database *odb, > > free(alts); > > } > > > > -void odb_add_to_alternates_memory(struct object_database *odb, > > - const char *reference) > > +struct odb_source *odb_add_to_alternates_memory(struct object_database *odb, > > + const char *reference) > > { > > + struct odb_source *alternate; > > + char *objdir; > > + > > /* > > * Make sure alternates are initialized, or else our entry may be > > * overwritten when they are. > > */ > > odb_prepare_alternates(odb); > > > > - link_alt_odb_entries(odb, reference, > > - '\n', NULL, 0); > > + objdir = real_pathdup(odb->sources->path, 1); > > + alternate = link_alt_odb_entry(odb, reference, NULL, 0, objdir); > > If I understand correctly, instead of using real_pathdup() we could > instead call: > > alternate = link_alt_odb_entry(odb, reference, "/", 0, odb->sources->path); > > I did not test this, but it would avoid duplicating the path here. I'm > not sure though whether it's easier to read. We can't quite, as the call to `alt_odb_usable()` needs the normalized object directory path so that it can figure out whether its local object directory is the same as the proposed new object directory. But what I noticed is that we're passing in redundant information: the path is already stored in `struct object_database`, and all callers of `link_alt_odb_entry()` pass both that ODB and its path. So we can drop the parameter and make it an internal implementation detail. Patrick