Skip to content

Commit 86d174b

Browse files
ttaylorrgitster
authored andcommitted
t/helper/test-read-midx.c: add '--show-objects'
The 'read-midx' helper is used in places like t5319 to display basic information about a multi-pack-index. In the next patch, the MIDX writing machinery will learn a new way to choose from which pack an object is selected when multiple copies of that object exist. To disambiguate which pack introduces an object so that this feature can be tested, add a '--show-objects' option which displays additional information about each object in the MIDX. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cd57bc4 commit 86d174b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

t/helper/test-read-midx.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "repository.h"
55
#include "object-store.h"
66

7-
static int read_midx_file(const char *object_dir)
7+
static int read_midx_file(const char *object_dir, int show_objects)
88
{
99
uint32_t i;
1010
struct multi_pack_index *m;
@@ -43,13 +43,29 @@ static int read_midx_file(const char *object_dir)
4343

4444
printf("object-dir: %s\n", m->object_dir);
4545

46+
if (show_objects) {
47+
struct object_id oid;
48+
struct pack_entry e;
49+
50+
for (i = 0; i < m->num_objects; i++) {
51+
nth_midxed_object_oid(&oid, m, i);
52+
fill_midx_entry(the_repository, &oid, &e, m);
53+
54+
printf("%s %"PRIu64"\t%s\n",
55+
oid_to_hex(&oid), e.offset, e.p->pack_name);
56+
}
57+
return 0;
58+
}
59+
4660
return 0;
4761
}
4862

4963
int cmd__read_midx(int argc, const char **argv)
5064
{
51-
if (argc != 2)
52-
usage("read-midx <object-dir>");
65+
if (!(argc == 2 || argc == 3))
66+
usage("read-midx [--show-objects] <object-dir>");
5367

54-
return read_midx_file(argv[1]);
68+
if (!strcmp(argv[1], "--show-objects"))
69+
return read_midx_file(argv[2], 1);
70+
return read_midx_file(argv[1], 0);
5571
}

0 commit comments

Comments
 (0)