]> git.ipfire.org Git - thirdparty/git.git/commit
refs: implement logic to migrate between ref storage formats
authorPatrick Steinhardt <ps@pks.im>
Thu, 6 Jun 2024 05:29:45 +0000 (07:29 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Jun 2024 16:04:33 +0000 (09:04 -0700)
commit6d6a3a99c7c35093c4a39cbf4d20869e2db3a4d8
tree6958ec5338f3b0251f6bb2f4e6832c2203706030
parent64a6dd8ffc2f120fc13e438af3236aa00cebc241
refs: implement logic to migrate between ref storage formats

With the introduction of the new "reftable" backend, users may want to
migrate repositories between the backends without having to recreate the
whole repository. Add the logic to do so.

The implementation is generic and works with arbitrary ref storage
formats so that a backend does not need to implement any migration
logic. It does have a few limitations though:

  - We do not migrate repositories with worktrees, because worktrees
    have separate ref storages. It makes the overall affair more complex
    if we have to migrate multiple storages at once.

  - We do not migrate reflogs, because we have no interfaces to write
    many reflog entries.

  - We do not lock the repository for concurrent access, and thus
    concurrent writes may end up with weird in-between states. There is
    no way to fully lock the "files" backend for writes due to its
    format, and thus we punt on this topic altogether and defer to the
    user to avoid those from happening.

In other words, this version is a minimum viable product for migrating a
repository's ref storage format. It works alright for bare repos, which
often have neither worktrees nor reflogs. But it will not work for many
other repositories without some preparations. These limitations are not
set into stone though, and ideally we will eventually address them over
time.

The logic is not yet used by anything, and thus there are no tests for
it. Those will be added in the next commit.

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