git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 4/8] repository: stop initializing the object database in `repo_set_gitdir()`

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 4, 2026, 06:08 UTC
Message-ID
<aiEWZo7Y-UXK4N3x@pks.im>
In-Reply-To
<CAOLa=ZQ5u+J-f=xS7RDym0cwt+=R2dzMFo5P34cp-CBbza7NRg@mail.gmail.com>
On Wed, Jun 03, 2026 at 05:49:50AM -0700, Karthik Nayak wrote:
Show 19 quoted lines
> Patrick Steinhardt <ps@pks.im> 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
Previous: Karthik NayakNext: Patrick Steinhardt
Message 12 of 17 in “setup: centralize object database creation”
  1. 0/8 setup: centralize object database creationPatrick Steinhardt, May 26, 2026
  2. 1/8 t0001: plug test gaps for git-init(1) with GIT_OBJECT_DIRECTORYPatrick Steinhardt, May 26, 2026
  3. Karthik NayakJun 3, 2026
  4. 2/8 setup: drop `setup_git_env()`Patrick Steinhardt, May 26, 2026
  5. 3/8 setup: deduplicate logic to apply repository formatPatrick Steinhardt, May 26, 2026
  6. Karthik NayakJun 3, 2026
  7. Patrick SteinhardtJun 4, 2026
  8. 5/8 setup: stop creating the object database in `setup_git_env()`Patrick Steinhardt, May 26, 2026
  9. Karthik NayakJun 3, 2026
  10. 4/8 repository: stop initializing the object database in `repo_set_gitdir()`Patrick Steinhardt, May 26, 2026
  11. Karthik NayakJun 3, 2026
  12. Patrick SteinhardtJun 4, 2026
  13. 6/8 setup: stop initializing object database without repositoryPatrick Steinhardt, May 26, 2026
  14. 7/8 repository: stop reading loose object map twice on repo initPatrick Steinhardt, May 26, 2026
  15. 8/8 setup: construct object database in `apply_repository_format()`Patrick Steinhardt, May 26, 2026
  16. Karthik NayakJun 3, 2026
  17. Patrick SteinhardtJun 4, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.