Imported Upstream version 2.27.0
[platform/upstream/git.git] / t / helper / test-read-graph.c
1 #include "test-tool.h"
2 #include "cache.h"
3 #include "commit-graph.h"
4 #include "repository.h"
5 #include "object-store.h"
6
7 int cmd__read_graph(int argc, const char **argv)
8 {
9         struct commit_graph *graph = NULL;
10         struct object_directory *odb;
11
12         setup_git_directory();
13         odb = the_repository->objects->odb;
14
15         graph = read_commit_graph_one(the_repository, odb);
16         if (!graph)
17                 return 1;
18
19
20         printf("header: %08x %d %d %d %d\n",
21                 ntohl(*(uint32_t*)graph->data),
22                 *(unsigned char*)(graph->data + 4),
23                 *(unsigned char*)(graph->data + 5),
24                 *(unsigned char*)(graph->data + 6),
25                 *(unsigned char*)(graph->data + 7));
26         printf("num_commits: %u\n", graph->num_commits);
27         printf("chunks:");
28
29         if (graph->chunk_oid_fanout)
30                 printf(" oid_fanout");
31         if (graph->chunk_oid_lookup)
32                 printf(" oid_lookup");
33         if (graph->chunk_commit_data)
34                 printf(" commit_metadata");
35         if (graph->chunk_extra_edges)
36                 printf(" extra_edges");
37         if (graph->chunk_bloom_indexes)
38                 printf(" bloom_indexes");
39         if (graph->chunk_bloom_data)
40                 printf(" bloom_data");
41         printf("\n");
42
43         UNLEAK(graph);
44
45         return 0;
46 }