From: Karthik Nayak Date: Mon, 09 Nov 2026 15:23:52 GMT Subject: Re: reftable: wrong HEAD reflog when its target is updated in the same transaction Message-ID: In-Reply-To: 井上司 writes: > Karthik Nayak 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. >> 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 : [snip]