Skip to content

Commit 460b156

Browse files
ttaylorrgitster
authored andcommitted
t/helper/test-read-graph.c: extract dump_graph_info()
Prepare for the 'read-graph' test helper to perform other tasks besides dumping high-level information about the commit-graph by extracting its main routine into a separate function. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 23e91c0 commit 460b156

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

t/helper/test-read-graph.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,8 @@
55
#include "bloom.h"
66
#include "setup.h"
77

8-
int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
8+
static void dump_graph_info(struct commit_graph *graph)
99
{
10-
struct commit_graph *graph = NULL;
11-
struct object_directory *odb;
12-
13-
setup_git_directory();
14-
odb = the_repository->objects->odb;
15-
16-
prepare_repo_settings(the_repository);
17-
18-
graph = read_commit_graph_one(the_repository, odb);
19-
if (!graph)
20-
return 1;
21-
2210
printf("header: %08x %d %d %d %d\n",
2311
ntohl(*(uint32_t*)graph->data),
2412
*(unsigned char*)(graph->data + 4),
@@ -57,6 +45,23 @@ int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
5745
if (graph->topo_levels)
5846
printf(" topo_levels");
5947
printf("\n");
48+
}
49+
50+
int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
51+
{
52+
struct commit_graph *graph = NULL;
53+
struct object_directory *odb;
54+
55+
setup_git_directory();
56+
odb = the_repository->objects->odb;
57+
58+
prepare_repo_settings(the_repository);
59+
60+
graph = read_commit_graph_one(the_repository, odb);
61+
if (!graph)
62+
return 1;
63+
64+
dump_graph_info(graph);
6065

6166
UNLEAK(graph);
6267

0 commit comments

Comments
 (0)