git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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]
Previous: 井上司Next: tsukasa inoue
Message 4 of 8 in “reftable: wrong HEAD reflog when its target is updated in the same transaction”
  1. 井上司Nov 8, 2026
  2. Karthik NayakNov 8, 2026
  3. 井上司Nov 9, 2026
  4. Karthik NayakNov 9, 2026
  5. refs: fix reflog of a symref whose target is in the same transactiontsukasa inoue, Nov 10, 2026
  6. Karthik NayakNov 12, 2026
  7. 井上司Nov 13, 2026
  8. refs: fix reflog of a symref whose target is in the same transactiontsukasa inoue, Nov 17, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.