diff options
| author | Taylor Blau <me@ttaylorr.com> | 2021-08-31 16:52:28 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-09-01 13:56:43 -0700 |
| commit | b1b82d1c3006ff9e25873d4ff01f976a13b526bb (patch) | |
| tree | 803ba42ebaf91e6412393d26164e2a355ac65ffd /t/helper/test-read-midx.c | |
| parent | aeb4657242a4f7d9e507f88b24652f30f748cb56 (diff) | |
| download | git-b1b82d1c3006ff9e25873d4ff01f976a13b526bb.tar.gz | |
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/test-read-midx.c')
| -rw-r--r-- | t/helper/test-read-midx.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c index 7c2eb11a8e..cb0d27049a 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); } |
