# Reftable writes the wrong HEAD reflog when a transaction updates HEAD's target

_With the reftable backend, a transaction that updates a branch and points HEAD at it logs the branch's old value, or nothing at all, unlike the files backend._

Section: Bugs. Edition of 2026-11-18. Written by an AI editor from the thread "reftable: wrong HEAD reflog when its target is updated in the same transaction" (8 messages): https://gitlist.dev/t/66806

The report, from 井上司 (tsukasa inoue), gives a reproducer on current master. In a reftable repository, a git update-ref --stdin transaction updates refs/heads/y and then runs symref-update HEAD refs/heads/y. The new HEAD reflog entry records y's old value. If y is created in the same transaction, no HEAD reflog entry is written. The files backend records the new value in both cases.

A follow-up from tsukasa inoue explains the cause. Both backends obtain the value for the HEAD reflog entry by resolving the target with refs_resolve_ref_unsafe(), which reads refs as they stood before the transaction was applied. The reftable backend writes all updates into a single table at the end, so it always sees the old value of y. When y is created by the same transaction, it sees no y at all, treats the symref as dangling, and writes no reflog entry.

The files backend commits updates one at a time in queue order, so, according to the follow-up, it produces the correct value only when of the ordering of updates happens to help. The excerpt breaks off at that point.

Karthik Nayak took part in the thread, which has eight messages; the excerpts do not show what was concluded or whether a fix has been proposed.
