summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2021-08-31 20:52:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-01 20:56:43 (GMT)
commitb1b82d1c3006ff9e25873d4ff01f976a13b526bb (patch)
tree803ba42ebaf91e6412393d26164e2a355ac65ffd /t/helper
parentaeb4657242a4f7d9e507f88b24652f30f748cb56 (diff)
downloadgit-b1b82d1c3006ff9e25873d4ff01f976a13b526bb.zip
git-b1b82d1c3006ff9e25873d4ff01f976a13b526bb.tar.gz
git-b1b82d1c3006ff9e25873d4ff01f976a13b526bb.tar.bz2
t/helper/test-read-midx.c: add --checksum mode
Subsequent tests will want to check for the existence of a multi-pack bitmap which matches the multi-pack-index stored in the pack directory. The multi-pack bitmap includes the hex checksum of the MIDX it corresponds to in its filename (for example, '$packdir/multi-pack-index-<checksum>.bitmap'). As a result, some tests want a way to learn what '<checksum>' is. This helper addresses that need by printing the checksum of the repository's multi-pack-index. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-read-midx.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index 7c2eb11..cb0d270 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -60,12 +60,26 @@ static int read_midx_file(const char *object_dir, int show_objects)
return 0;
}
+static int read_midx_checksum(const char *object_dir)
+{
+ struct multi_pack_index *m;
+
+ setup_git_directory();
+ m = load_multi_pack_index(object_dir, 1);
+ if (!m)
+ return 1;
+ printf("%s\n", hash_to_hex(get_midx_checksum(m)));
+ return 0;
+}
+
int cmd__read_midx(int argc, const char **argv)
{
if (!(argc == 2 || argc == 3))
- usage("read-midx [--show-objects] <object-dir>");
+ usage("read-midx [--show-objects|--checksum] <object-dir>");
if (!strcmp(argv[1], "--show-objects"))
return read_midx_file(argv[2], 1);
+ else if (!strcmp(argv[1], "--checksum"))
+ return read_midx_checksum(argv[2]);
return read_midx_file(argv[1], 0);
}