refs: add support for migrating reflogs

The `git refs migrate` command was introduced in
25a0023f28 (builtin/refs: new command to migrate ref storage formats,
2024-06-06) to support migrating from one reference backend to another.

One limitation of the command was that it didn't support migrating
repositories which contained reflogs. A previous commit, added support
for adding reflog updates in ref transactions. Using the added
functionality bake in reflog support for `git refs migrate`.

To ensure that the order of the reflogs is maintained during the
migration, we add the index for each reflog update as we iterate over
the reflogs from the old reference backend. This is to ensure that the
order is maintained in the new backend.

Helped-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Karthik Nayak
2024-12-16 17:44:33 +01:00
committed by Junio C Hamano
parent 297c09eabb
commit 246cebe320
3 changed files with 115 additions and 52 deletions

View File

@ -57,8 +57,6 @@ KNOWN LIMITATIONS
The ref format migration has several known limitations in its current form:
* It is not possible to migrate repositories that have reflogs.
* It is not possible to migrate repositories that have worktrees.
* There is no way to block concurrent writes to the repository during an