]> Kevux Git Server - rit/commit
refs: simplify logic when migrating reflog entries
authorPatrick Steinhardt <ps@pks.im>
Thu, 31 Jul 2025 14:56:50 +0000 (16:56 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Aug 2025 21:19:30 +0000 (14:19 -0700)
commit2f530e5d0ac9349ad5884a7d74a60762e4ee05f8
tree39dfb5ac0be9b684fede7248ee86c5108073a25a
parentb9fd73a234db1a272f6cbfb528bae0ead9e07bde
refs: simplify logic when migrating reflog entries

When migrating reflog entries between two storage formats we have to do
so via two callback-driven functions:

  - `migrate_one_reflog()` gets invoked via `refs_for_each_reflog()` to
    first list all available reflogs.

  - `migrate_one_reflog_entry()` gets invoked via
    `refs_for_each_reflog_ent()` in `migrate_one_reflog()`.

Before the preceding commit we didn't have the refname available in
`migrate_one_reflog_entry()`, which made it necessary to have a separate
structure that we pass to the second callback so that we can propagate
the refname. Now that `refs_for_each_reflog_ent()` knows to pass the
refname to the callback though that indirection isn't necessary anymore.

There's one catch though: we do have an update index that is also stored
in the entry-specific callback data. This update index is required so
that we can tell the ref backend in which order it should persist the
reflog entries to disk.

But that purpose can be trivially achieved by just converting it into a
global counter that is used for all reflog entries, regardless of which
reference they are for. The ordering will remain the same as both the
update index and the refname is considered when sorting the entries.

Move the index into `struct migration_data` and drop the now-unused
`struct reflog_migration_data` to simplify the code a bit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c