]> git.ipfire.org Git - thirdparty/git.git/commit
refs: fix invalid old object IDs when migrating reflogs
authorPatrick Steinhardt <ps@pks.im>
Wed, 6 Aug 2025 05:54:20 +0000 (07:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Aug 2025 14:36:31 +0000 (07:36 -0700)
commit465eff81de44763832e96fbe609ec269f1c23ade
tree57b162ac07d2cc68b0bc97ec0ad52fb042ad6dd9
parent046c67325c66f9e29e3bbe249ee742477b7525ef
refs: fix invalid old object IDs when migrating reflogs

When migrating reflog entries between different storage formats we end
up with invalid old object IDs for the migrated entries: instead of
writing the old object ID of the to-be-migrated entry, we end up with
the all-zeroes object ID.

The root cause of this issue is that we don't know to use the old object
ID provided by the caller. Instead, we manually resolve the old object
ID by resolving the current value of its matching reference. But as that
reference does not yet exist in the target ref storage we always end up
resolving it to all-zeroes.

This issue got unnoticed as there is no user-facing command that would
even show the old object ID. While `git log -g` knows to show the new
object ID, we don't have any formatting directive to show the old object
ID.

Fix the bug by introducing a new flag `REF_LOG_USE_PROVIDED_OIDS`. If
set, backends are instructed to use the old and new object IDs provided
by the caller, without doing any manual resolving. Set this flag in
`ref_transaction_update_reflog()`.

Amend our tests in t1460-refs-migrate to use our test tool to read
reflog entries. This test tool prints out both old and new object ID of
each reflog entry, which fixes the test gap. Furthermore it also prints
the full identity used to write the reflog, which provides test coverage
for the previous commit in this patch series that fixed the identity for
migrated reflogs.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs.h
refs/files-backend.c
refs/reftable-backend.c
t/t1421-reflog-write.sh
t/t1460-refs-migrate.sh