Files
git/t/helper/test-bitmap.c
Lidong Yan bfd5522e98 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>
2025-07-01 14:41:54 -07:00

64 lines
1.7 KiB
C

#define USE_THE_REPOSITORY_VARIABLE
#include "test-tool.h"
#include "git-compat-util.h"
#include "pack-bitmap.h"
#include "setup.h"
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);
}
static int bitmap_dump_pseudo_merges(void)
{
return test_bitmap_pseudo_merges(the_repository);
}
static int bitmap_dump_pseudo_merge_commits(uint32_t n)
{
return test_bitmap_pseudo_merge_commits(the_repository, n);
}
static int bitmap_dump_pseudo_merge_objects(uint32_t n)
{
return test_bitmap_pseudo_merge_objects(the_repository, n);
}
int cmd__bitmap(int argc, const char **argv)
{
setup_git_directory();
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"))
return bitmap_dump_pseudo_merges();
if (argc == 3 && !strcmp(argv[1], "dump-pseudo-merge-commits"))
return bitmap_dump_pseudo_merge_commits(atoi(argv[2]));
if (argc == 3 && !strcmp(argv[1], "dump-pseudo-merge-objects"))
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"
"\ttest-tool bitmap dump-pseudo-merge-objects <n>");
return -1;
}