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 <me@ttaylorr.com> Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Jun 25, 2024 at 13:39 UTC
460b15699dcadae5a642fbf67276cbeb85ea035c
1 file changed
+18
-13
t/helper/test-read-graph.c
+18
-13
@@ -5,20 +5,8 @@
5
#include "bloom.h"
6
#include "setup.h"
7
8
-int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
8
+static void dump_graph_info(struct commit_graph *graph)
9
{
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
-
10
printf("header: %08x %d %d %d %d\n",
11
ntohl(*(uint32_t*)graph->data),
12
*(unsigned char*)(graph->data + 4),
@@ -57,6 +45,23 @@ int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
45
if (graph->topo_levels)
46
printf(" topo_levels");
47
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);
65
66
UNLEAK(graph);
67