Merge branch 'ds/maintenance-part-3'
[git] / t / helper / test-read-midx.c
1 #include "test-tool.h"
2 #include "cache.h"
3 #include "midx.h"
4 #include "repository.h"
5 #include "object-store.h"
6
7 static int read_midx_file(const char *object_dir)
8 {
9         uint32_t i;
10         struct multi_pack_index *m;
11
12         setup_git_directory();
13         m = load_multi_pack_index(object_dir, 1);
14
15         if (!m)
16                 return 1;
17
18         printf("header: %08x %d %d %d %d\n",
19                m->signature,
20                m->version,
21                m->hash_len,
22                m->num_chunks,
23                m->num_packs);
24
25         printf("chunks:");
26
27         if (m->chunk_pack_names)
28                 printf(" pack-names");
29         if (m->chunk_oid_fanout)
30                 printf(" oid-fanout");
31         if (m->chunk_oid_lookup)
32                 printf(" oid-lookup");
33         if (m->chunk_object_offsets)
34                 printf(" object-offsets");
35         if (m->chunk_large_offsets)
36                 printf(" large-offsets");
37
38         printf("\nnum_objects: %d\n", m->num_objects);
39
40         printf("packs:\n");
41         for (i = 0; i < m->num_packs; i++)
42                 printf("%s\n", m->pack_names[i]);
43
44         printf("object-dir: %s\n", m->object_dir);
45
46         return 0;
47 }
48
49 int cmd__read_midx(int argc, const char **argv)
50 {
51         if (argc != 2)
52                 usage("read-midx <object-dir>");
53
54         return read_midx_file(argv[1]);
55 }