On Wed, Feb 28, 2018 at 3:12 AM, Brandon Williams <bmw...@google.com> wrote: > On 02/27, Nguyễn Thái Ngọc Duy wrote: >> diff --git a/repository.c b/repository.c >> index 7654b8ada9..e326f0fcbc 100644 >> --- a/repository.c >> +++ b/repository.c >> @@ -61,6 +61,8 @@ void repo_set_gitdir(struct repository *repo, >> repo_set_commondir(repo, o->shared_root); >> expand_base_dir(&repo->objects.objectdir, o->object_dir, >> repo->commondir, "objects"); >> + free(repo->objects.alternate_db); >> + repo->objects.alternate_db = xstrdup_or_null(o->alternate_db); > > Just a note that this only works because the object store is embedded in > the repository struct, it isn't a pointer to an object store.
It is possible to make it work even if object store is not embedded though. From my point of view, this function is about "give me $GIT_DIR and optionally the where all other parts are, if you ignore default repo layout and tear the repository apart". We could initialize the object store later when it's created and pass the relevant paths to it. Exactly where it's safe to "create and initialize object store" is harder to see now because the whole main repo setup is spread out over many many functions. -- Duy