Skip to content

Commit 483fa7f

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dff5e49 commit 483fa7f

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ X =
693693
PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
694694

695695
TEST_BUILTINS_OBJS += test-advise.o
696+
TEST_BUILTINS_OBJS += test-bitmap.o
696697
TEST_BUILTINS_OBJS += test-bloom.o
697698
TEST_BUILTINS_OBJS += test-chmtime.o
698699
TEST_BUILTINS_OBJS += test-config.o

t/helper/test-bitmap.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct test_cmd {
1515

1616
static struct test_cmd cmds[] = {
1717
{ "advise", cmd__advise_if_enabled },
18+
{ "bitmap", cmd__bitmap },
1819
{ "bloom", cmd__bloom },
1920
{ "chmtime", cmd__chmtime },
2021
{ "config", cmd__config },

t/helper/test-tool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "git-compat-util.h"
66

77
int cmd__advise_if_enabled(int argc, const char **argv);
8+
int cmd__bitmap(int argc, const char **argv);
89
int cmd__bloom(int argc, const char **argv);
910
int cmd__chmtime(int argc, const char **argv);
1011
int cmd__config(int argc, const char **argv);

0 commit comments

Comments
 (0)