t/helper/test-bitmap.c: initial commit

Add a new 'bitmap' test-tool which can be used to list the commits that have received bitmaps. In theory, a determined tester could run 'git rev-list --test-bitmap <commit>' to check if '<commit>' received a bitmap or not, since '--test-bitmap' exits with a non-zero code when it can't find the requested commit. But this is a dubious behavior to rely on, since arguably 'git rev-list' could continue its object walk outside of which commits are covered by bitmaps. This will be used to test the behavior of 'pack.preferBitmapTips', which will be added in the following patch. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Mar 31, 2021 at 21:32 UTC 483fa7f42d9e7723154aa1baa6e1576cf51cc64b
4 files changed +27
Makefile
+1
@@ -693,6 +693,7 @@ X =
693 PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
694
695 TEST_BUILTINS_OBJS += test-advise.o
696 +TEST_BUILTINS_OBJS += test-bitmap.o
697 TEST_BUILTINS_OBJS += test-bloom.o
698 TEST_BUILTINS_OBJS += test-chmtime.o
699 TEST_BUILTINS_OBJS += test-config.o
t/helper/test-bitmap.c new
+24
@@ -0,0 +1,24 @@
1 +#include "test-tool.h"
2 +#include "cache.h"
3 +#include "pack-bitmap.h"
4 +
5 +static int bitmap_list_commits(void)
6 +{
7 + return test_bitmap_commits(the_repository);
8 +}
9 +
10 +int cmd__bitmap(int argc, const char **argv)
11 +{
12 + setup_git_directory();
13 +
14 + if (argc != 2)
15 + goto usage;
16 +
17 + if (!strcmp(argv[1], "list-commits"))
18 + return bitmap_list_commits();
19 +
20 +usage:
21 + usage("\ttest-tool bitmap list-commits");
22 +
23 + return -1;
24 +}
t/helper/test-tool.c
+1
@@ -15,6 +15,7 @@ struct test_cmd {
15
16 static struct test_cmd cmds[] = {
17 { "advise", cmd__advise_if_enabled },
18 + { "bitmap", cmd__bitmap },
19 { "bloom", cmd__bloom },
20 { "chmtime", cmd__chmtime },
21 { "config", cmd__config },
t/helper/test-tool.h
+1
@@ -5,6 +5,7 @@
5 #include "git-compat-util.h"
6
7 int cmd__advise_if_enabled(int argc, const char **argv);
8 +int cmd__bitmap(int argc, const char **argv);
9 int cmd__bloom(int argc, const char **argv);
10 int cmd__chmtime(int argc, const char **argv);
11 int cmd__config(int argc, const char **argv);