Message ID | bc89bcd9c8c9b33e517a21bbe7c441538e288ebc.1588018418.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Reftable support git-core | expand |
On Mon, Apr 27, 2020 at 08:13:29PM +0000, Han-Wen Nienhuys via GitGitGadget wrote: > > > This prepares for supporting the reftable format, which will want > create its own file system layout in .git > > Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> > --- > builtin/init-db.c | 2 -- > refs/files-backend.c | 6 ++++++ > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/builtin/init-db.c b/builtin/init-db.c > index 0b7222e7188..3b50b1aa0e5 100644 > --- a/builtin/init-db.c > +++ b/builtin/init-db.c > @@ -251,8 +251,6 @@ static int create_default_files(const char *template_path, > * We need to create a "refs" dir in any case so that older > * versions of git can tell that this is a repository. > */ > - safe_create_dir(git_path("refs"), 1); > - adjust_shared_perm(git_path("refs")); Is the reftable completely replacing the refs/ dir? Or is the idea that the refs/ dir is only used by the files backend? The commit message makes it sound like it's an additional format to support, so I'm a little confused. Why does the other currently-existing backend not need the refs/ dir at this stage? > > if (refs_init_db(&err)) > die("failed to set up refs db: %s", err.buf); > diff --git a/refs/files-backend.c b/refs/files-backend.c > index 561c33ac8a9..ab7899a9c77 100644 > --- a/refs/files-backend.c > +++ b/refs/files-backend.c > @@ -3157,9 +3157,15 @@ static int files_init_db(struct ref_store *ref_store, struct strbuf *err) > files_downcast(ref_store, REF_STORE_WRITE, "init_db"); > struct strbuf sb = STRBUF_INIT; > > + files_ref_path(refs, &sb, "refs"); > + safe_create_dir(sb.buf, 1); > + /* adjust permissions even if directory already exists. */ > + adjust_shared_perm(sb.buf); > + > /* > * Create .git/refs/{heads,tags} > */ > + strbuf_reset(&sb); > files_ref_path(refs, &sb, "refs/heads"); > safe_create_dir(sb.buf, 1); > > -- > gitgitgadget >
Emily Shaffer <emilyshaffer@google.com> writes: >> - safe_create_dir(git_path("refs"), 1); >> - adjust_shared_perm(git_path("refs")); > > Is the reftable completely replacing the refs/ dir? Or is the idea that > the refs/ dir is only used by the files backend? The commit message > makes it sound like it's an additional format to support, so I'm a > little confused. Why does the other currently-existing backend not need > the refs/ dir at this stage? Other current backend being the files-backend, which creates it below, isn't this a no-op at this stage? What's more interesting is what would happen when a repo is initialized with the reftable backend as its sole backend. Even then, the repository discovery code of existing versions of Git needs to see a directory with a ".git" subdirectory, in the latter of which there must be HEAD and objects and refs subdirectories, so we'd need to create refs/ directory even if reftable does not use it. This step, from that point of view, may not be necessary. But as long as we make sure any repository creates refs/ and objects/ directories, regardless of the ref backend, we'd be OK.
On Thu, Apr 30, 2020 at 11:24 PM Emily Shaffer <emilyshaffer@google.com> wrote: > > On Mon, Apr 27, 2020 at 08:13:29PM +0000, Han-Wen Nienhuys via GitGitGadget wrote: > > > > > > This prepares for supporting the reftable format, which will want > > create its own file system layout in .git > > > > Signed-off-by: Han-Wen Nienhuys <hanwen@google.com> > > --- > > builtin/init-db.c | 2 -- > > refs/files-backend.c | 6 ++++++ > > 2 files changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/builtin/init-db.c b/builtin/init-db.c > > index 0b7222e7188..3b50b1aa0e5 100644 > > --- a/builtin/init-db.c > > +++ b/builtin/init-db.c > > @@ -251,8 +251,6 @@ static int create_default_files(const char *template_path, > > * We need to create a "refs" dir in any case so that older > > * versions of git can tell that this is a repository. > > */ > > - safe_create_dir(git_path("refs"), 1); > > - adjust_shared_perm(git_path("refs")); > > Is the reftable completely replacing the refs/ dir? Or is the idea that > the refs/ dir is only used by the files backend? The commit message > makes it sound like it's an additional format to support, so I'm a > little confused. Why does the other currently-existing backend not need > the refs/ dir at this stage? I've dropped this patch from the series; it probably was from before the compat hack that is described in https://git.eclipse.org/r/#/c/157167/ for further clarification: reftable doesn't used the refs/ dir at all, but we still want to not confuse older git versions.
diff --git a/builtin/init-db.c b/builtin/init-db.c index 0b7222e7188..3b50b1aa0e5 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -251,8 +251,6 @@ static int create_default_files(const char *template_path, * We need to create a "refs" dir in any case so that older * versions of git can tell that this is a repository. */ - safe_create_dir(git_path("refs"), 1); - adjust_shared_perm(git_path("refs")); if (refs_init_db(&err)) die("failed to set up refs db: %s", err.buf); diff --git a/refs/files-backend.c b/refs/files-backend.c index 561c33ac8a9..ab7899a9c77 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3157,9 +3157,15 @@ static int files_init_db(struct ref_store *ref_store, struct strbuf *err) files_downcast(ref_store, REF_STORE_WRITE, "init_db"); struct strbuf sb = STRBUF_INIT; + files_ref_path(refs, &sb, "refs"); + safe_create_dir(sb.buf, 1); + /* adjust permissions even if directory already exists. */ + adjust_shared_perm(sb.buf); + /* * Create .git/refs/{heads,tags} */ + strbuf_reset(&sb); files_ref_path(refs, &sb, "refs/heads"); safe_create_dir(sb.buf, 1);