git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] t/helper/test-bitmap.c: initial commit

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 1, 2021, 01:32 UTC
Message-ID
<ec974bb0c85bcde00d45e983d701c538488550a6.1617240723.git.me@ttaylorr.com>
In-Reply-To
<cover.1617240723.git.me@ttaylorr.com>

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>
---
 Makefile               |  1 +
 t/helper/test-bitmap.c | 24 ++++++++++++++++++++++++
 t/helper/test-tool.c   |  1 +
 t/helper/test-tool.h   |  1 +
 4 files changed, 27 insertions(+)
 create mode 100644 t/helper/test-bitmap.c
diff --git a/Makefile b/Makefile
index 55c8035fa8..89b30495eb 100644
--- 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
index 0000000000..134a1e9d76
--- /dev/null
+++ b/t/helper/test-bitmap.c
@@ -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;
+}
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index f97cd9f48a..a48bd44116 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -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 },
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index 28072c0ad5..563fe1b030 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -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);
-- 
2.31.1.163.ga65ce7f831
Previous: Taylor BlauNext: Ævar Arnfjörð Bjarmason
Message 3 of 13 in “pack-objects: introduce pack.preferBitmapTips”
  1. 0/3 pack-objects: introduce pack.preferBitmapTipsTaylor Blau, Apr 1, 2021
  2. 1/3 pack-bitmap: add 'test_bitmap_commits()' helperTaylor Blau, Apr 1, 2021
  3. 2/3 t/helper/test-bitmap.c: initial commitTaylor Blau, Apr 1, 2021
  4. SunCC doesn't compile v2.32.0-rc* anymore (was "Re: [PATCH 2/3] t/helper/test-bitmap.c: initial commit")Ævar Arnfjörð Bjarmason, May 26, 2021
  5. Taylor BlauMay 26, 2021
  6. Ævar Arnfjörð BjarmasonMay 26, 2021
  7. pack-objects: move builtin-only code to its own headerÆvar Arnfjörð Bjarmason, May 27, 2021
  8. Junio C HamanoMay 27, 2021
  9. Junio C HamanoMay 27, 2021
  10. Junio C HamanoMay 27, 2021
  11. Ævar Arnfjörð BjarmasonMay 27, 2021
  12. 3/3 builtin/pack-objects.c: respect 'pack.preferBitmapTips'Taylor Blau, Apr 1, 2021
  13. Derrick StoleeApr 1, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.