t4216: add end to end tests for git log with Bloom filters
[git/debian.git] / t / helper / test-read-graph.c
blob4223ff32fb69a1c8e498d0543a737dff44946640
1 #include "test-tool.h"
2 #include "cache.h"
3 #include "commit-graph.h"
4 #include "repository.h"
5 #include "object-store.h"
7 int cmd__read_graph(int argc, const char **argv)
9 struct commit_graph *graph = NULL;
10 char *graph_name;
11 int open_ok;
12 int fd;
13 struct stat st;
14 struct object_directory *odb;
16 setup_git_directory();
17 odb = the_repository->objects->odb;
19 graph_name = get_commit_graph_filename(odb);
21 open_ok = open_commit_graph(graph_name, &fd, &st);
22 if (!open_ok)
23 die_errno(_("Could not open commit-graph '%s'"), graph_name);
25 graph = load_commit_graph_one_fd_st(fd, &st, odb);
26 if (!graph)
27 return 1;
29 FREE_AND_NULL(graph_name);
31 printf("header: %08x %d %d %d %d\n",
32 ntohl(*(uint32_t*)graph->data),
33 *(unsigned char*)(graph->data + 4),
34 *(unsigned char*)(graph->data + 5),
35 *(unsigned char*)(graph->data + 6),
36 *(unsigned char*)(graph->data + 7));
37 printf("num_commits: %u\n", graph->num_commits);
38 printf("chunks:");
40 if (graph->chunk_oid_fanout)
41 printf(" oid_fanout");
42 if (graph->chunk_oid_lookup)
43 printf(" oid_lookup");
44 if (graph->chunk_commit_data)
45 printf(" commit_metadata");
46 if (graph->chunk_extra_edges)
47 printf(" extra_edges");
48 if (graph->chunk_bloom_indexes)
49 printf(" bloom_indexes");
50 if (graph->chunk_bloom_data)
51 printf(" bloom_data");
52 printf("\n");
54 UNLEAK(graph);
56 return 0;