|
4 | 4 | #include "repository.h"
|
5 | 5 | #include "object-store.h"
|
6 | 6 |
|
7 |
| -static int read_midx_file(const char *object_dir) |
| 7 | +static int read_midx_file(const char *object_dir, int show_objects) |
8 | 8 | {
|
9 | 9 | uint32_t i;
|
10 | 10 | struct multi_pack_index *m;
|
@@ -43,13 +43,29 @@ static int read_midx_file(const char *object_dir)
|
43 | 43 |
|
44 | 44 | printf("object-dir: %s\n", m->object_dir);
|
45 | 45 |
|
| 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 | + |
46 | 60 | return 0;
|
47 | 61 | }
|
48 | 62 |
|
49 | 63 | int cmd__read_midx(int argc, const char **argv)
|
50 | 64 | {
|
51 |
| - if (argc != 2) |
52 |
| - usage("read-midx <object-dir>"); |
| 65 | + if (!(argc == 2 || argc == 3)) |
| 66 | + usage("read-midx [--show-objects] <object-dir>"); |
53 | 67 |
|
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); |
55 | 71 | }
|
0 commit comments