]> git.ipfire.org Git - thirdparty/git.git/commit
refs: allow multiple reflog entries for the same refname
authorKarthik Nayak <karthik.188@gmail.com>
Mon, 16 Dec 2024 16:44:32 +0000 (17:44 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Dec 2024 17:45:34 +0000 (09:45 -0800)
commit297c09eabb1e8b44230bca86fc7fd344175e0be7
tree6dedcf0dab168a7f0720312d97c8ec4c635e8c5d
parent84675fa2717e08b39bf810eb9a439068ac915dfb
refs: allow multiple reflog entries for the same refname

The reference transaction only allows a single update for a given
reference to avoid conflicts. This, however, isn't an issue for reflogs.
There are no conflicts to be resolved in reflogs and when migrating
reflogs between backends we'd have multiple reflog entries for the same
refname.

So allow multiple reflog updates within a single transaction. Also the
reflog creation logic isn't exposed to the end user. While this might
change in the future, currently, this reduces the scope of issues to
think about.

In the reftable backend, the writer sorts all updates based on the
update_index before writing to the block. When there are multiple
reflogs for a given refname, it is essential that the order of the
reflogs is maintained. So add the `index` value to the `update_index`.
The `index` field is only set when multiple reflog entries for a given
refname are added and as such in most scenarios the old behavior
remains.

This is required to add reflog migration support to `git refs migrate`.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c
refs/reftable-backend.c