Re: reftable: wrong HEAD reflog when its target is updated in the same transaction
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Nov 9, 2026, 15:23 UTC
- Message-ID
- <CAOLa=ZTYevwM0YF0iQFnEwKG_buV7qg0QdjoaTkw0c8OQSd-mQ@mail.gmail.com>
- In-Reply-To
- <CAP8tz2KFb971L5_XY-hb8M=vfK-AsWwk_7YoMK6nCS8xhUKQ+Q@mail.gmail.com>
井上司 <inoue.tsukasa.4@gmail.com> writes:
Show 13 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes: > >> With the files backend, this isn't an issue only because the files >> backend doesn't support atomicity. If it did, we'd have the same bug >> there too ;) > > Thanks for looking at this so quickly. You're right, and it shows up > with files already. files commits the updates one by one in the order > they were queued, so the reflog is right only when the branch update > comes before HEAD. With "symref-update HEAD" first, files also records > the old oid, or no entry when the branch is created. I was wrong to say > files gets it right in both cases. >
Exactly. So it's a bigger bug than just reftables.
Show 11 quoted lines
>> I wonder if we can move move reflog logic to the generic 'refs.c' layer. > > I like that direction. As a first step toward it, I'd like to add a > helper in refs.c that returns the new oid of a ref updated in the same > transaction, and have both backends use it before falling back to > refs_resolve_ref_unsafe(). That fixes both backends whatever the order, > and one test can cover both. Moving the rest of the reflog logic to > refs.c could then come on top of that. > > Does that sound reasonable? >
Sounds like a good start to me! Looking forward to the patch. To also add more context, we've also been thinking about doing conflict resolution for updates within a given transaction for a while now. This seems to play into that.
So a transaction like:
delete refs/heads/foo create refs/heads/foo HEAD
would currently fail, which doesn't have to, but I haven't been able to put some time into this yet.
> Thanks, > Tsukasa > > 2026年11月9日(月) 7:18 Karthik Nayak <karthik.188@gmail.com>:
[snip]