3
#include "dir.h"
4
#include "lockfile.h"
5
#include "parse-options.h"
6
+#include "repository.h"
7
#include "commit-graph.h"
8
9
static char const * const builtin_commit_graph_usage[] = {
10
N_("git commit-graph [--object-dir <objdir>]"),
11
N_("git commit-graph read [--object-dir <objdir>]"),
12
+ N_("git commit-graph verify [--object-dir <objdir>]"),
13
N_("git commit-graph write [--object-dir <objdir>] [--append] [--stdin-packs|--stdin-commits]"),
14
NULL
15
};
16
17
+static const char * const builtin_commit_graph_verify_usage[] = {
18
+ N_("git commit-graph verify [--object-dir <objdir>]"),
19
+ NULL
20
+};
21
+
22
static const char * const builtin_commit_graph_read_usage[] = {
23
N_("git commit-graph read [--object-dir <objdir>]"),
24
NULL
36
int append;
37
} opts;
38
39
+
40
+static int graph_verify(int argc, const char **argv)
41
+{
42
+ struct commit_graph *graph = NULL;
43
+ char *graph_name;
44
+
45
+ static struct option builtin_commit_graph_verify_options[] = {
46
+ OPT_STRING(0, "object-dir", &opts.obj_dir,
47
+ N_("dir"),
48
+ N_("The object directory to store the graph")),
49
+ OPT_END(),
50
+ };
51
+
52
+ argc = parse_options(argc, argv, NULL,
53
+ builtin_commit_graph_verify_options,
54
+ builtin_commit_graph_verify_usage, 0);
55
+
56
+ if (!opts.obj_dir)
57
+ opts.obj_dir = get_object_directory();
58
+
59
+ graph_name = get_commit_graph_filename(opts.obj_dir);
60
+ graph = load_commit_graph_one(graph_name);
61
+ FREE_AND_NULL(graph_name);
62
+
63
+ if (!graph)
64
+ return 0;
65
+
66
+ return verify_commit_graph(the_repository, graph);
67
+}
68
+
69
static int graph_read(int argc, const char **argv)
70
{
71
struct commit_graph *graph = NULL;
202
if (argc > 0) {
203
if (!strcmp(argv[0], "read"))
204
return graph_read(argc, argv);
205
+ if (!strcmp(argv[0], "verify"))
206
+ return graph_verify(argc, argv);
207
if (!strcmp(argv[0], "write"))
208
return graph_write(argc, argv);
209
}