]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/repack.c
builtin/repack.c: pass `--refs-snapshot` when writing bitmaps
authorTaylor Blau <me@ttaylorr.com>
Fri, 1 Oct 2021 22:38:10 +0000 (18:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Oct 2021 23:40:09 +0000 (16:40 -0700)
commit324efc90d1b1a660388f8cabbb72e803160082d3
tree10b32d61e2634b390caf291ad67ca6b3f66ffdb7
parent6d08b9d4caa230441b7d9e2b4f23deaf9ff74c13
builtin/repack.c: pass `--refs-snapshot` when writing bitmaps

To prevent the race described in an earlier patch, generate and pass a
reference snapshot to the multi-pack bitmap code, if we are writing one
from `git repack`.

This patch is mostly limited to creating a temporary file, and then
calling for_each_ref(). Except we try to minimize duplicates, since
doing so can drastically reduce the size in network-of-forks style
repositories. In the kernel's fork network (the repository containing
all objects from the kernel and all its forks), deduplicating the
references drops the snapshot size from 934 MB to just 12 MB.

But since we're handling duplicates in this way, we have to make sure
that we preferred references (those listed in pack.preferBitmapTips)
before non-preferred ones (to avoid recording an object which is pointed
at by a preferred tip as non-preferred).

We accomplish this by doing separate passes over the references: first
visiting each prefix in pack.preferBitmapTips, and then over the rest of
the references.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c
t/t7700-repack.sh