]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper/test-read-graph.c: extract `dump_graph_info()`
authorTaylor Blau <me@ttaylorr.com>
Tue, 25 Jun 2024 17:39:37 +0000 (13:39 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Jun 2024 20:52:05 +0000 (13:52 -0700)
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>
t/helper/test-read-graph.c

index 8c7a83f578f41c3d90bcb17628bd5307e5927636..3375392f6c4d16f10f575a919dfacdd65e75701f 100644 (file)
@@ -5,20 +5,8 @@
 #include "bloom.h"
 #include "setup.h"
 
-int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
+static void dump_graph_info(struct commit_graph *graph)
 {
-       struct commit_graph *graph = NULL;
-       struct object_directory *odb;
-
-       setup_git_directory();
-       odb = the_repository->objects->odb;
-
-       prepare_repo_settings(the_repository);
-
-       graph = read_commit_graph_one(the_repository, odb);
-       if (!graph)
-               return 1;
-
        printf("header: %08x %d %d %d %d\n",
                ntohl(*(uint32_t*)graph->data),
                *(unsigned char*)(graph->data + 4),
@@ -57,6 +45,23 @@ int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
        if (graph->topo_levels)
                printf(" topo_levels");
        printf("\n");
+}
+
+int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)
+{
+       struct commit_graph *graph = NULL;
+       struct object_directory *odb;
+
+       setup_git_directory();
+       odb = the_repository->objects->odb;
+
+       prepare_repo_settings(the_repository);
+
+       graph = read_commit_graph_one(the_repository, odb);
+       if (!graph)
+               return 1;
+
+       dump_graph_info(graph);
 
        UNLEAK(graph);