Skip to content

Commit b1b82d1

Browse files
ttaylorrgitster
authored andcommitted
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>
1 parent aeb4657 commit b1b82d1

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

t/helper/test-read-midx.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,26 @@ static int read_midx_file(const char *object_dir, int show_objects)
6060
return 0;
6161
}
6262

63+
static int read_midx_checksum(const char *object_dir)
64+
{
65+
struct multi_pack_index *m;
66+
67+
setup_git_directory();
68+
m = load_multi_pack_index(object_dir, 1);
69+
if (!m)
70+
return 1;
71+
printf("%s\n", hash_to_hex(get_midx_checksum(m)));
72+
return 0;
73+
}
74+
6375
int cmd__read_midx(int argc, const char **argv)
6476
{
6577
if (!(argc == 2 || argc == 3))
66-
usage("read-midx [--show-objects] <object-dir>");
78+
usage("read-midx [--show-objects|--checksum] <object-dir>");
6779

6880
if (!strcmp(argv[1], "--show-objects"))
6981
return read_midx_file(argv[2], 1);
82+
else if (!strcmp(argv[1], "--checksum"))
83+
return read_midx_checksum(argv[2]);
7084
return read_midx_file(argv[1], 0);
7185
}

t/lib-bitmap.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,7 @@ have_delta () {
260260
echo $1 | git cat-file --batch-check="%(deltabase)" >actual &&
261261
test_cmp expect actual
262262
}
263+
264+
midx_checksum () {
265+
test-tool read-midx --checksum "$1"
266+
}

0 commit comments

Comments
 (0)