Re: [PATCH v3 15/20] init: allow alternate backends to be set for new repos
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 4, 2016, 09:48 UTC
- Message-ID
- <CACsJy8DUpOGtZmBr2F2R+8xvzvHOxLc_YOSnF8eQRvHYq15ttA@mail.gmail.com>
- In-Reply-To
- <1452788777-24954-16-git-send-email-dturner@twopensource.com>
(picking a random series version because I didn't follow it closely)
On Thu, Jan 14, 2016 at 11:26 PM, David Turner <dturner@twopensource.com> wrote:
Show 15 quoted lines
> + 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.
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.
-- Duy