]> git.ipfire.org Git - thirdparty/git.git/commit
refs: stop unsetting REF_HAVE_OLD for log-only updates
authorPatrick Steinhardt <ps@pks.im>
Wed, 6 Aug 2025 05:54:19 +0000 (07:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Aug 2025 14:36:31 +0000 (07:36 -0700)
commit046c67325c66f9e29e3bbe249ee742477b7525ef
tree5a681792262c39947c44036787a23bb347968db7
parent211fa8b2d016208e1f37727c118a073dd415bed1
refs: stop unsetting REF_HAVE_OLD for log-only updates

The `REF_HAVE_OLD` flag indicates whether a given ref update has its old
object ID set. If so, the value of that field is used to verify whether
the current state of the reference matches this expected state. It is
thus an important part of mitigating races with a concurrent process
that updates the same set of references.

When writing reflogs though we explicitly unset that flag. This is a
sensible thing to do: the old state of reflog entry updates may not
necessarily match the current on-disk state of its accompanying ref, but
it's only intended to signal what old object ID we want to write into
the new reflog entry. For example when migrating refs we end up writing
many reflog entries for a single reference, and most likely those reflog
entries will have many different old object IDs.

But unsetting this flag also removes a useful signal, namely that the
caller _did_ provide an old object ID for a given reflog entry. This
signal will become useful in a subsequent commit, where we add a new
flag that tells the transaction to use the provided old and new object
IDs to write a reflog entry. The `REF_HAVE_OLD` flag is then used as a
signal to verify that the caller really did provide an old object ID.

Stop unsetting the flag so that we can use it as this described signal
in a subsequent commit. Skip checking the old object ID for log-only
updates so that we don't expect it to match the current on-disk state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs/files-backend.c
refs/refs-internal.h
refs/reftable-backend.c