Skip to content

Commit 0e4747e

Browse files
chriscoolgitster
authored andcommitted
pack-bitmap-write: rebuild using new bitmap when remapping
`git repack` is about to learn a new `--filter=<filter-spec>` option and we will want to check that this option is incompatible with `--write-bitmap-index`. Unfortunately it appears that a test like: test_expect_success '--filter fails with --write-bitmap-index' ' test_must_fail \ env GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 \ git -C bare.git repack -a -d --write-bitmap-index --filter=blob:none ' sometimes fail because when rebuilding bitmaps, it appears that we are reusing existing bitmap information. So instead of detecting that some objects are missing and erroring out as it should, the `git repack --write-bitmap-index --filter=...` command succeeds. Let's fix that by making sure we rebuild bitmaps using new bitmaps instead of existing ones. Helped-by: Taylor Blau <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent be315e9 commit 0e4747e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pack-bitmap-write.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,15 +413,19 @@ static int fill_bitmap_commit(struct bb_commit *ent,
413413

414414
if (old_bitmap && mapping) {
415415
struct ewah_bitmap *old = bitmap_for_commit(old_bitmap, c);
416+
struct bitmap *remapped = bitmap_new();
416417
/*
417418
* If this commit has an old bitmap, then translate that
418419
* bitmap and add its bits to this one. No need to walk
419420
* parents or the tree for this commit.
420421
*/
421-
if (old && !rebuild_bitmap(mapping, old, ent->bitmap)) {
422+
if (old && !rebuild_bitmap(mapping, old, remapped)) {
423+
bitmap_or(ent->bitmap, remapped);
424+
bitmap_free(remapped);
422425
reused_bitmaps_nr++;
423426
continue;
424427
}
428+
bitmap_free(remapped);
425429
}
426430

427431
/*

0 commit comments

Comments
 (0)