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)
27 static struct option builtin_commit_graph_write_options[] = {
28 { OPTION_STRING, 'o', "object-dir", &opts.obj_dir,
30 N_("The object directory to store the graph") },
34 argc = parse_options(argc, argv, NULL,
35 builtin_commit_graph_write_options,
36 builtin_commit_graph_write_usage, 0);
39 opts.obj_dir = get_object_directory();
41 graph_name = write_commit_graph(opts.obj_dir);
44 printf("%s\n", graph_name);
45 FREE_AND_NULL(graph_name);
51 int cmd_commit_graph(int argc, const char **argv, const char *prefix)
53 static struct option builtin_commit_graph_options[] = {
54 { OPTION_STRING, 'o', "object-dir", &opts.obj_dir,
56 N_("The object directory to store the graph") },
60 if (argc == 2 && !strcmp(argv[1], "-h"))
61 usage_with_options(builtin_commit_graph_usage,
62 builtin_commit_graph_options);
64 git_config(git_default_config, NULL);
65 argc = parse_options(argc, argv, prefix,
66 builtin_commit_graph_options,
67 builtin_commit_graph_usage,
68 PARSE_OPT_STOP_AT_NON_OPTION);
71 if (!strcmp(argv[0], "write"))
72 return graph_write(argc, argv);
75 usage_with_options(builtin_commit_graph_usage,
76 builtin_commit_graph_options);