git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: David Turner <dturner@twopensource.com>
To: Michael Haggerty <mhagger@alum.mit.edu>, git@vger.kernel.org
Cc: "SZEDER Gábor" <szeder@ira.uka.de>
Subject: Re: [PATCH v4 15/21] init: allow alternate ref strorage to be set for new repos
Date: Wed, 17 Feb 2016 15:47:16 -0500	[thread overview]
Message-ID: <1455742036.7528.18.camel@twopensource.com> (raw)
In-Reply-To: <56BDF9B1.5050302@alum.mit.edu>

On Fri, 2016-02-12 at 16:26 +0100, Michael Haggerty wrote:
> On 02/05/2016 08:44 PM, David Turner wrote:
> > git init learns a new argument --ref-storage.  Presently, only
> > "files" is supported, but later we will add other storage backends.
> > 
> > When this argument is used, the repository's extensions.refStorage
> > configuration value is set (as well as
> > core.repositoryformatversion),
> > and the ref storage backend's initdb function is used to set up the
> > ref database.
> > 
> > Signed-off-by: David Turner <dturner@twopensource.com>
> > Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
> > ---
> >  Documentation/git-init-db.txt          |  2 +-
> >  Documentation/git-init.txt             |  7 +++++-
> >  builtin/init-db.c                      | 44
> > +++++++++++++++++++++++++++-------
> >  cache.h                                |  2 ++
> >  contrib/completion/git-completion.bash |  3 ++-
> >  path.c                                 | 29 ++++++++++++++++++++--
> >  refs.c                                 |  8 +++++++
> >  refs.h                                 |  8 +++++++
> >  setup.c                                | 12 ++++++++++
> >  t/t0001-init.sh                        | 25 +++++++++++++++++++
> >  10 files changed, 127 insertions(+), 13 deletions(-)
> > 
> > [...]
> > diff --git a/Documentation/git-init.txt b/Documentation/git
> > -init.txt
> > index 8174d27..d2b150f 100644
> > --- a/Documentation/git-init.txt
> > +++ b/Documentation/git-init.txt
> > @@ -12,7 +12,7 @@ SYNOPSIS
> >  'git init' [-q | --quiet] [--bare] [-
> > -template=<template_directory>]
> >  	  [--separate-git-dir <git dir>]
> >  	  [--shared[=<permissions>]] [directory]
> > -
> > +	  [--ref-storage=<name>]
> >  
> >  DESCRIPTION
> >  -----------
> > @@ -113,6 +113,11 @@ does not exist, it will be created.
> >  
> >  --
> >  
> > +--ref-storage=<name>::
> > +Type of refs storage backend. Default is to use the original
> > "files"
> > +storage, which stores ref data in files in .git/refs and
> > +.git/packed-refs.
> > +
> 
> Technically, that should be $GIT_DIR/refs and $GIT_DIR/packed-refs.
> But
> it might be that we are not so picky about the distinction in the
> user docs.

We're not (according to grep), but we probably should be.

> >  TEMPLATE DIRECTORY
> >  ------------------
> >  
> > diff --git a/builtin/init-db.c b/builtin/init-db.c
> > index 801e977..d331ce8 100644
> > --- a/builtin/init-db.c
> > +++ b/builtin/init-db.c
> > @@ -24,6 +24,7 @@ static int init_is_bare_repository = 0;
> >  static int init_shared_repository = -1;
> >  static const char *init_db_template_dir;
> >  static const char *git_link;
> > +static char *requested_ref_storage_backend;
> >  
> >  static void copy_templates_1(struct strbuf *path, struct strbuf
> > *template,
> >  			     DIR *dir)
> > @@ -179,6 +180,7 @@ static int create_default_files(const char
> > *template_path)
> >  	int reinit;
> >  	int filemode;
> >  	struct strbuf err = STRBUF_INIT;
> > +	int repo_version = 0;
> >  
> >  	/* Just look for `init.templatedir` */
> >  	git_config(git_init_db_config, NULL);
> > @@ -205,6 +207,32 @@ static int create_default_files(const char
> > *template_path)
> >  	}
> >  
> >  	/*
> > +	 * Create the default symlink from ".git/HEAD" to the
> > "master"
> 
> I know that you are just moving this comment, but s/symlink/symref/
> would make it more up-to-date.

OK.

> > +	 * branch, if it does not exist yet.
> > +	 */
> > [...]
> > diff --git a/setup.c b/setup.c
> > index 0deb022..1a62277 100644
> > --- a/setup.c
> > +++ b/setup.c
> > @@ -1,5 +1,6 @@
> >  #include "cache.h"
> >  #include "dir.h"
> > +#include "refs.h"
> >  #include "string-list.h"
> >  
> >  static int inside_git_dir = -1;
> > @@ -263,6 +264,15 @@ int get_common_dir_noenv(struct strbuf *sb,
> > const char *gitdir)
> >  	return ret;
> >  }
> >  
> > +int ref_storage_backend_config(const char *var, const char *value,
> > void *ptr)
> > +{
> > +	char **cdata = ptr;
> > +
> > +	if (!strcmp(var, "extensions.refstorage"))
> > +		*cdata = xstrdup(value);
> > +	return 0;
> > +}
> > +
> >  /*
> >   * Test if it looks like we're at a git directory.
> >   * We want to see:
> > @@ -390,6 +400,8 @@ static int check_repo_format(const char *var,
> > const char *value, void *cb)
> >  			;
> >  		else if (!strcmp(ext, "preciousobjects"))
> >  			repository_format_precious_objects =
> > git_config_bool(var, value);
> > +		else if (!strcmp(ext, "refstorage"))
> > +			ref_storage_backend = xstrdup(value);
> >  		else
> >  			string_list_append(&unknown_extensions,
> > ext);
> >  	}
> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> > index 295aa59..31c8279 100755
> > --- a/t/t0001-init.sh
> > +++ b/t/t0001-init.sh
> > @@ -174,6 +174,31 @@ test_expect_success 'reinit' '
> >  	test_i18ncmp again/empty again/err2
> >  '
> >  
> > +test_expect_success 'init with bogus storage backend fails' '
> > +
> > +	(
> > +		mkdir again2 &&
> > +		cd again2 &&
> > +		test_must_fail git init --ref-storage=test >out2
> > 2>err2 &&
> > +		test_i18ngrep "Unknown ref storage backend test"
> > err2
> > +	)
> > +'
> > +
> > +test_expect_failure 'reinit with changed storage backend fails' '
> > +
> > +	(
> > +		mkdir again3 &&
> > +		cd again3 &&
> > +		git init >out1 2>err1 &&
> > +		git init --ref-storage=test >out2 2>err2
> > +	) &&
> > +	test_i18ngrep "Initialized empty" again3/out1 &&
> > +	test_i18ngrep "Reinitialized existing" again3/out2 &&
> > +	>again3/empty &&
> > +	test_i18ncmp again3/empty again3/err1 &&
> > +	test_i18ncmp again3/empty again3/err2
> > +'
> > +
> 
> Is it worth testing re-initializing with the same --ref-storage?
> Perhaps
> not.

Would be nice, but since we cannot guarantee that any alternate backend
exists, we have no way to test this.  We'd have to add an entire "test"
ref backend just for tests, which seems a bit overboard.

> >  test_expect_success 'init with --template' '
> >  	mkdir template-source &&
> >  	echo content >template-source/file &&
> > 
> 
> Michael
> 

  reply	other threads:[~2016-02-17 20:47 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05 19:44 [PATCH v4 00/20] refs backend David Turner
2016-02-05 19:44 ` [PATCH v4 01/21] refs: add a backend method structure with transaction functions David Turner
2016-02-05 19:44 ` [PATCH v4 02/21] refs: add methods for misc ref operations David Turner
2016-02-11  7:45   ` Michael Haggerty
2016-02-12  1:09     ` David Turner
2016-02-05 19:44 ` [PATCH v4 03/21] refs: add methods for the ref iterators David Turner
2016-02-11  8:42   ` Michael Haggerty
2016-02-12  1:08     ` David Turner
2016-02-05 19:44 ` [PATCH v4 04/21] refs: add do_for_each_per_worktree_ref David Turner
2016-02-05 19:44 ` [PATCH v4 05/21] refs: add methods for reflog David Turner
2016-02-05 19:44 ` [PATCH v4 06/21] refs: add method for initial ref transaction commit David Turner
2016-02-05 19:44 ` [PATCH v4 07/21] refs: add method for delete_refs David Turner
2016-02-05 19:44 ` [PATCH v4 08/21] refs: add methods to init refs db David Turner
2016-02-11  8:54   ` Michael Haggerty
2016-02-11 21:15     ` David Turner
2016-02-05 19:44 ` [PATCH v4 09/21] refs: add method to rename refs David Turner
2016-02-11  9:00   ` Michael Haggerty
2016-02-11 21:12     ` David Turner
2016-02-05 19:44 ` [PATCH v4 10/21] refs: make lock generic David Turner
2016-02-05 19:44 ` [PATCH v4 11/21] refs: move duplicate check to common code David Turner
2016-02-05 19:44 ` [PATCH v4 12/21] refs: allow log-only updates David Turner
2016-02-11 10:03   ` Michael Haggerty
2016-02-11 21:23     ` David Turner
2016-02-05 19:44 ` [PATCH v4 13/21] refs: resolve symbolic refs first David Turner
2016-02-12 14:09   ` Michael Haggerty
2016-02-18  0:29     ` David Turner
2016-02-18 11:59       ` Michael Haggerty
2016-02-05 19:44 ` [PATCH v4 14/21] refs: always handle non-normal refs in files backend David Turner
2016-02-12 15:07   ` Michael Haggerty
2016-02-18  2:44     ` David Turner
2016-02-18 12:07       ` Michael Haggerty
2016-02-18 18:32         ` David Turner
2016-02-05 19:44 ` [PATCH v4 15/21] init: allow alternate ref strorage to be set for new repos David Turner
2016-02-12 15:26   ` Michael Haggerty
2016-02-17 20:47     ` David Turner [this message]
2016-02-18 14:12       ` Michael Haggerty
2016-02-05 19:44 ` [PATCH v4 16/21] refs: check submodules ref storage config David Turner
2016-02-05 19:44 ` [PATCH v4 17/21] clone: allow ref storage backend to be set for clone David Turner
2016-02-05 19:44 ` [PATCH v4 18/21] svn: learn ref-storage argument David Turner
2016-02-05 19:44 ` [PATCH v4 19/21] refs: add register_ref_storage_backends() David Turner
2016-02-12 15:42   ` Michael Haggerty
2016-02-17 20:32     ` David Turner
2016-02-05 19:44 ` [PATCH v4 20/21] refs: add LMDB refs storage backend David Turner
2016-02-11  8:48   ` Michael Haggerty
2016-02-11 21:21     ` David Turner
2016-02-12 17:01   ` Michael Haggerty
2016-02-13  1:23     ` David Turner
2016-02-14 12:04   ` Duy Nguyen
2016-02-15  9:57     ` Duy Nguyen
2016-02-16 22:01       ` David Turner
2016-02-17 20:32     ` David Turner
2016-02-05 19:44 ` [PATCH v4 21/21] refs: tests for lmdb backend David Turner
2016-02-08 23:37 ` [PATCH v4 00/20] refs backend Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455742036.7528.18.camel@twopensource.com \
    --to=dturner@twopensource.com \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=szeder@ira.uka.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).