Subject: Re: [PATCH v3 15/20] init: allow alternate backends to be set for new repos

From: David Turner <[email-masked]>
Date: Thu, 04 Feb 2016 15:05:08 -0500

On Thu, 2016-02-04 at 16:48 +0700, Duy Nguyen wrote:
> (picking a random series version because I didn't follow it closely)
> 
> On Thu, Jan 14, 2016 at 11:26 PM, David Turner <
> [email-masked]> wrote:
> > +       if (requested_ref_storage_backend)
> > +               ref_storage_backend =
> > requested_ref_storage_backend;
> > +       if (strcmp(ref_storage_backend, "files")) {
> > +               git_config_set("extensions.refStorage",
> > ref_storage_backend);
> > +               git_config_set("core.repositoryformatversion",
> > ref_storage_backend);
> > +#ifdef USE_LIBLMDB
> > +               register_ref_storage_backend(&refs_be_lmdb);
> > +#endif
> > +               set_ref_storage_backend(ref_storage_backend);
> > +               repo_version = 1;
> > +       }
> > +
> > +       if (refs_init_db(&err, shared_repository))
> > +               die("failed to set up refs db: %s", err.buf);
> > +
> 
> I was surprised that "git init --ref-storage=lmdb abc" ran
> successfully even on non-lmdb build. Of course running any commands
> in
> the new repo will fail, suggesting to rebuild with lmdb. But should
> "git init" fail in the first place? I see Thomas' comment about this
> block, but not sure why it still passes for me. It does not catch
> unrecognized backend names either.

This was broken in this patchset and is fixed in the set I've got in
-progress (with a test).

> Also it would be nice if we could hide #ifdef USE_LIBLMDB (here and
> in
> config.c) away, maybe in refs directory. I imagine a new backend
> would
> need the same set of #ifdef. Spreading them across files does not
> sound ideal.

Good point. Moved to a single one in refs.c.  Thanks.