mirror of
https://github.com/git/git.git
synced 2026-03-29 11:00:07 +02:00
pack-bitmap: add load corrupt bitmap test
t5310 lacks a test to ensure git works correctly when commit bitmap data is corrupted. So this patch add test helper in pack-bitmap.c to list each commit bitmap position in bitmap file and `load corrupt bitmap` test case in t/t5310 to corrupt a commit bitmap before loading it. Signed-off-by: Lidong Yan <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
73bf771b95
commit
bfd5522e98
@@ -10,6 +10,11 @@ static int bitmap_list_commits(void)
|
||||
return test_bitmap_commits(the_repository);
|
||||
}
|
||||
|
||||
static int bitmap_list_commits_with_offset(void)
|
||||
{
|
||||
return test_bitmap_commits_with_offset(the_repository);
|
||||
}
|
||||
|
||||
static int bitmap_dump_hashes(void)
|
||||
{
|
||||
return test_bitmap_hashes(the_repository);
|
||||
@@ -36,6 +41,8 @@ int cmd__bitmap(int argc, const char **argv)
|
||||
|
||||
if (argc == 2 && !strcmp(argv[1], "list-commits"))
|
||||
return bitmap_list_commits();
|
||||
if (argc == 2 && !strcmp(argv[1], "list-commits-with-offset"))
|
||||
return bitmap_list_commits_with_offset();
|
||||
if (argc == 2 && !strcmp(argv[1], "dump-hashes"))
|
||||
return bitmap_dump_hashes();
|
||||
if (argc == 2 && !strcmp(argv[1], "dump-pseudo-merges"))
|
||||
@@ -46,6 +53,7 @@ int cmd__bitmap(int argc, const char **argv)
|
||||
return bitmap_dump_pseudo_merge_objects(atoi(argv[2]));
|
||||
|
||||
usage("\ttest-tool bitmap list-commits\n"
|
||||
"\ttest-tool bitmap list-commits-with-offset\n"
|
||||
"\ttest-tool bitmap dump-hashes\n"
|
||||
"\ttest-tool bitmap dump-pseudo-merges\n"
|
||||
"\ttest-tool bitmap dump-pseudo-merge-commits <n>\n"
|
||||
|
||||
@@ -486,6 +486,36 @@ test_bitmap_cases () {
|
||||
grep "ignoring extra bitmap" trace2.txt
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'load corrupt bitmap' '
|
||||
rm -fr repo &&
|
||||
git init repo &&
|
||||
test_when_finished "rm -fr repo" &&
|
||||
(
|
||||
cd repo &&
|
||||
git config pack.writeBitmapLookupTable '"$writeLookupTable"' &&
|
||||
|
||||
test_commit base &&
|
||||
|
||||
git repack -adb &&
|
||||
bitmap="$(ls .git/objects/pack/pack-*.bitmap)" &&
|
||||
chmod +w $bitmap &&
|
||||
|
||||
test-tool bitmap list-commits-with-offset >offsets &&
|
||||
xor_off=$(head -n1 offsets | awk "{print \$3}") &&
|
||||
printf '\161' |
|
||||
dd of=$bitmap count=1 bs=1 conv=notrunc seek=$xor_off &&
|
||||
|
||||
git rev-list --objects --no-object-names HEAD >expect.raw &&
|
||||
git rev-list --objects --use-bitmap-index --no-object-names HEAD \
|
||||
>actual.raw &&
|
||||
|
||||
sort expect.raw >expect &&
|
||||
sort actual.raw >actual &&
|
||||
|
||||
test_cmp expect actual
|
||||
)
|
||||
'
|
||||
}
|
||||
|
||||
test_bitmap_cases
|
||||
|
||||
Reference in New Issue
Block a user