From: Patrick Steinhardt Date: Thu, 04 Jun 2026 06:08:38 GMT Subject: Re: [PATCH v2 4/8] repository: stop initializing the object database in `repo_set_gitdir()` Message-ID: In-Reply-To: On Wed, Jun 03, 2026 at 05:49:50AM -0700, Karthik Nayak wrote: > Patrick Steinhardt writes: > > diff --git a/repository.c b/repository.c > > index 58a13f7c4f..2c2395105f 100644 > > --- a/repository.c > > +++ b/repository.c > > @@ -181,12 +181,6 @@ void repo_set_gitdir(struct repository *repo, > > free(old_gitdir); > > > > repo_set_commondir(repo, o->commondir); > > - > > - if (!repo->objects) > > - repo->objects = odb_new(repo, o->object_dir, o->alternate_db); > > - else if (!o->skip_initializing_odb) > > - BUG("cannot reinitialize an already-initialized object directory"); > > - > > This always confuses me, so we were creating the odb even if > `o->skip_initializing_odb` was set to true, if `repo->objects` didn't > exist. Weird. Agreed, it was weird. It was my first iteration towards centralizing `odb_new()`: before we had the above logic we were basically recreating the ODB multiple times, which was even more weird. At least things are getting somewhat sensible with this patch now. Patrick