Skip to content

Commit

Permalink
pack-objects: turn off bitmaps when we split packs
Browse files Browse the repository at this point in the history
If a pack.packSizeLimit is set, we may split the pack data
across multiple packfiles. This means we cannot generate
.bitmap files, as they require that all of the reachable
objects are in the same pack. We check that condition when
we are generating the list of objects to pack (and disable
bitmaps if we are not packing everything), but we forgot to
update it when we notice that we needed to split (which
doesn't happen until the actual write phase).

The resulting bitmaps are quite bogus (they mention entries
that do not exist in the pack!) and can cause a fetch or
push to send insufficient objects.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Oct 19, 2014
1 parent 76f8611 commit 2113471
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ static void write_pack_file(void)
fixup_pack_header_footer(fd, sha1, pack_tmp_name,
nr_written, sha1, offset);
close(fd);
write_bitmap_index = 0;
}

if (!pack_to_stdout) {
Expand Down
9 changes: 9 additions & 0 deletions t/t5310-pack-bitmaps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,13 @@ test_expect_success JGIT 'jgit can read our bitmaps' '
)
'

test_expect_success 'splitting packs does not generate bogus bitmaps' '
test-genrandom foo $((1024 * 1024)) >rand &&
git add rand &&
git commit -m "commit with big file" &&
git -c pack.packSizeLimit=500k repack -adb &&
git init --bare no-bitmaps.git &&
git -C no-bitmaps.git fetch .. HEAD
'

test_done

0 comments on commit 2113471

Please sign in to comment.