]> git.ipfire.org Git - thirdparty/git.git/commit
pseudo-merge: implement support for finding existing merges
authorTaylor Blau <me@ttaylorr.com>
Thu, 23 May 2024 21:27:21 +0000 (17:27 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 May 2024 18:40:44 +0000 (11:40 -0700)
commit7252d9a036fabb10f60dc09937fc39e252f3c4d4
tree7c011869a40a48d7fc450cd9e76fa00c3773c2da
parent94c1addf862619250a1584c05a43f80f1c8d7d72
pseudo-merge: implement support for finding existing merges

This patch implements support for reusing existing pseudo-merge commits
when writing bitmaps when there is an existing pseudo-merge bitmap which
has exactly the same set of parents as one that we are about to write.

Note that unstable pseudo-merges are likely to change between
consecutive repacks, and so are generally poor candidates for reuse.
However, stable pseudo-merges (see the configuration option
'bitmapPseudoMerge.<name>.stableThreshold') are by definition unlikely
to change between runs (as they represent long-running branches).

Because there is no index from a *set* of pseudo-merge parents to a
matching pseudo-merge bitmap, we have to construct the bitmap
corresponding to the set of parents for each pending pseudo-merge commit
and see if a matching bitmap exists.

This is technically quadratic in the number of pseudo-merges, but is OK
in practice for a couple of reasons:

  - non-matching pseudo-merge bitmaps are rejected quickly as soon as
    they differ in a single bit

  - already-matched pseudo-merge bitmaps are discarded from subsequent
    rounds of search

  - the number of pseudo-merges is generally small, even for large
    repositories

In order to do this, implement (a) a function that finds a matching
pseudo-merge given some uncompressed bitset describing its parents, (b)
a function that computes the bitset of parents for a given pseudo-merge
commit, and (c) call that function before computing the set of reachable
objects for some pending pseudo-merge.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-bitmap-write.c
pack-bitmap.c
pack-bitmap.h
pseudo-merge.c
pseudo-merge.h
t/t5333-pseudo-merge-bitmaps.sh