]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper/test-bitmap.c: initial commit
authorTaylor Blau <me@ttaylorr.com>
Thu, 1 Apr 2021 01:32:11 +0000 (21:32 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Apr 2021 06:14:03 +0000 (23:14 -0700)
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>
Makefile
t/helper/test-bitmap.c [new file with mode: 0644]
t/helper/test-tool.c
t/helper/test-tool.h

index 55c8035fa80bd099d2872df28a3c80753aea4710..89b30495ebce1e46e29f3169e76ab5081943f06f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -693,6 +693,7 @@ X =
 PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 
 TEST_BUILTINS_OBJS += test-advise.o
+TEST_BUILTINS_OBJS += test-bitmap.o
 TEST_BUILTINS_OBJS += test-bloom.o
 TEST_BUILTINS_OBJS += test-chmtime.o
 TEST_BUILTINS_OBJS += test-config.o
diff --git a/t/helper/test-bitmap.c b/t/helper/test-bitmap.c
new file mode 100644 (file)
index 0000000..134a1e9
--- /dev/null
@@ -0,0 +1,24 @@
+#include "test-tool.h"
+#include "cache.h"
+#include "pack-bitmap.h"
+
+static int bitmap_list_commits(void)
+{
+       return test_bitmap_commits(the_repository);
+}
+
+int cmd__bitmap(int argc, const char **argv)
+{
+       setup_git_directory();
+
+       if (argc != 2)
+               goto usage;
+
+       if (!strcmp(argv[1], "list-commits"))
+               return bitmap_list_commits();
+
+usage:
+       usage("\ttest-tool bitmap list-commits");
+
+       return -1;
+}
index f97cd9f48a69048db519ffc0519a99559f543b31..a48bd441160bfbca7a78c036e7f1e3229786daf8 100644 (file)
@@ -15,6 +15,7 @@ struct test_cmd {
 
 static struct test_cmd cmds[] = {
        { "advise", cmd__advise_if_enabled },
+       { "bitmap", cmd__bitmap },
        { "bloom", cmd__bloom },
        { "chmtime", cmd__chmtime },
        { "config", cmd__config },
index 28072c0ad5ab446eab4b37d915222b6768dc2e66..563fe1b030ef3230d57462e55d4feab680a246d5 100644 (file)
@@ -5,6 +5,7 @@
 #include "git-compat-util.h"
 
 int cmd__advise_if_enabled(int argc, const char **argv);
+int cmd__bitmap(int argc, const char **argv);
 int cmd__bloom(int argc, const char **argv);
 int cmd__chmtime(int argc, const char **argv);
 int cmd__config(int argc, const char **argv);