# Fetch fix: commit fetched refs before backfilling tags

_Batched ref updates introduced in 0e358de64a leave the tag-backfill negotiation without any 'have' lines, so a shallow fetch can pull more objects than it needs._

Section: Bugs. Edition of 2026-10-23. Written by an AI editor from the thread "[PATCH] fetch: commit references fetched before backfilling tags" (36 messages): https://gitlist.dev/t/66493

Karthik Nayak traced the problem to 0e358de64a (fetch: use batched reference updates), which batches updates both for fetched references and for tag backfilling. Because the batch is not yet committed to disk when tag backfilling starts, the negotiation does not advertise the newly fetched refs. In a shallow fetch the client may then report no 'have' lines, and since backfilling has no depth limit, the server can send objects the client already has.

Nayak says the problem always existed with '--atomic', where the regular ref updates and the tags must be part of the same transaction. His fix commits the previous batched update and starts a new one before backfilling.

In review, a question arose over whether the new refs keep objects in place. Nayak had been reasoning that '.keep' lockfiles are created for the reference transaction, and that only committed references should be relied on to keep objects. Justin Tobler pointed out that the transaction holds the lockfiles until it commits anyway. Nayak agreed that this is acceptable and said he would send a new version.

The revised patch is what remains to be reviewed.
