Subject: Re: [PATCH v2 5/6] reftable/stack: allow passing flags to `reftable_stack_add()`

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 12 Aug 2025 11:27:54 +0200

On Mon, Aug 11, 2025 at 02:34:49PM -0500, Justin Tobler wrote:
> On 25/08/04 11:40AM, Patrick Steinhardt wrote:
> > diff --git a/reftable/stack.c b/reftable/stack.c
> > index d6e4ea93a37..f77d7f58e8e 100644
> > --- a/reftable/stack.c
> > +++ b/reftable/stack.c
> > @@ -737,10 +737,10 @@ static int reftable_stack_init_addition(struct reftable_addition *add,
> >  static int stack_try_add(struct reftable_stack *st,
> >  			 int (*write_table)(struct reftable_writer *wr,
> >  					    void *arg),
> > -			 void *arg)
> > +			 void *arg, unsigned flags)
> >  {
> >  	struct reftable_addition add = REFTABLE_ADDITION_INIT;
> > -	int err = reftable_stack_init_addition(&add, st, 0);
> > +	int err = reftable_stack_init_addition(&add, st, flags);
> 
> Ok, so now if the `REFTABLE_STACK_NEW_ADDITION_RELOAD` flag is provided,
> reftable_stack_init_addition() will attempt to reload the stack if it is
> outdated before locking the stack. I assume Git itself hasn't needed
> this because it just uses reftable_stack_new_addition() directly when
> neccessary.

Not in all code paths, and arguably Git should pass the flag in those
code paths that don't yet. We already perform all verification under the
lock anyway, so this would be the right thing to do.

In this patch series I wanted to focus on improvements to the library
for now, not to the backend. But honestly, there isn't really a good
reason to not already fix this while we're working on this.

Patrick