5 #include "parse-options.h"
6 #include "commit-graph.h"
8 static char const * const builtin_commit_graph_usage[] = {
9 N_("git commit-graph [--object-dir <objdir>]"),
10 N_("git commit-graph write [--object-dir <objdir>]"),
14 static const char * const builtin_commit_graph_write_usage[] = {
15 N_("git commit-graph write [--object-dir <objdir>]"),
19 static struct opts_commit_graph {
23 static int graph_write(int argc, const char **argv)
25 static struct option builtin_commit_graph_write_options[] = {
26 OPT_STRING(0, "object-dir", &opts.obj_dir,
28 N_("The object directory to store the graph")),
32 argc = parse_options(argc, argv, NULL,
33 builtin_commit_graph_write_options,
34 builtin_commit_graph_write_usage, 0);
37 opts.obj_dir = get_object_directory();
39 write_commit_graph(opts.obj_dir);
43 int cmd_commit_graph(int argc, const char **argv, const char *prefix)
45 static struct option builtin_commit_graph_options[] = {
46 OPT_STRING(0, "object-dir", &opts.obj_dir,
48 N_("The object directory to store the graph")),
52 if (argc == 2 && !strcmp(argv[1], "-h"))
53 usage_with_options(builtin_commit_graph_usage,
54 builtin_commit_graph_options);
56 git_config(git_default_config, NULL);
57 argc = parse_options(argc, argv, prefix,
58 builtin_commit_graph_options,
59 builtin_commit_graph_usage,
60 PARSE_OPT_STOP_AT_NON_OPTION);
63 if (!strcmp(argv[0], "write"))
64 return graph_write(argc, argv);
67 usage_with_options(builtin_commit_graph_usage,
68 builtin_commit_graph_options);