Patrick Steinhardt <ps@xxxxxx> writes: > The reftable ref store needs to keep track of multiple stacks, one for > the main worktree and an arbitrary number of stacks for worktrees. This > is done by storing pointers to `struct reftable_stack`, which we then > access directly. > > Wrap the stack in a new `struct reftable_backend`. This will allow us to > attach more data to each respective stack in subsequent commits. > > Signed-off-by: Patrick Steinhardt <ps@xxxxxx> > --- > refs/reftable-backend.c | 129 +++++++++++++++++++++++----------------- > 1 file changed, 73 insertions(+), 56 deletions(-) > > diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c > index 38eb14d591..43cba53cb1 100644 > --- a/refs/reftable-backend.c > +++ b/refs/reftable-backend.c > @@ -32,6 +32,23 @@ > */ > #define REF_UPDATE_VIA_HEAD (1 << 8) > > +struct reftable_backend { > + struct reftable_stack *stack; > +}; > + > +static int reftable_backend_init(struct reftable_backend *be, > + const char *path, > + const struct reftable_write_options *opts) > +{ > + return reftable_new_stack(&be->stack, path, opts); > +} > + > +static void reftable_backend_release(struct reftable_backend *be) > +{ > + reftable_stack_destroy(be->stack); > + be->stack = NULL; > +} > + > struct reftable_ref_store { > struct ref_store base; > > @@ -39,17 +56,17 @@ struct reftable_ref_store { > * The main stack refers to the common dir and thus contains common > * refs as well as refs of the main repository. > */ Shouldn't these comments be updated to say s/stack/backend, while the backend contains the stack, it is confusing to read stack and see backend. > - struct reftable_stack *main_stack; > + struct reftable_backend main_backend; > /* > * The worktree stack refers to the gitdir in case the refdb is opened > * via a worktree. It thus contains the per-worktree refs. > */ Here too. > - struct reftable_stack *worktree_stack; > + struct reftable_backend worktree_backend; > /* > * Map of worktree stacks by their respective worktree names. The map > * is populated lazily when we try to resolve `worktrees/$worktree` refs. > */ Here too. > - struct strmap worktree_stacks; > + struct strmap worktree_backends; > struct reftable_write_options write_options; > > unsigned int store_flags; [snip] > @@ -772,14 +789,14 @@ static struct ref_iterator *reftable_be_iterator_begin(struct ref_store *ref_sto > * right now. If we aren't, then we return the common reftable > * iterator, only. > */ > - if (!refs->worktree_stack) > + if (!refs->worktree_backend.stack) Nit: Not your fault, but this is misaligned no? > return &main_iter->base; > [snip]
Attachment:
signature.asc
Description: PGP signature