commit-graph: create git-commit-graph builtin

Teach git the 'commit-graph' builtin that will be used for writing and reading packed graph files. The current implementation is mostly empty, except for an '--object-dir' option. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Apr 2, 2018 at 16:34 UTC 4ce58ee38de3ab0955b94946bfc339f387227223
8 files changed +53
.gitignore
+1
@@ -34,6 +34,7 @@
34 /git-clone
35 /git-column
36 /git-commit
37 +/git-commit-graph
38 /git-commit-tree
39 /git-config
40 /git-count-objects
Documentation/git-commit-graph.txt new
+10
@@ -0,0 +1,10 @@
1 +git-commit-graph(1)
2 +===================
3 +
4 +NAME
5 +----
6 +git-commit-graph - Write and verify Git commit graph files
7 +
8 +GIT
9 +---
10 +Part of the linkgit:git[1] suite
Makefile
+1
@@ -946,6 +946,7 @@ BUILTIN_OBJS += builtin/clone.o
946 BUILTIN_OBJS += builtin/column.o
947 BUILTIN_OBJS += builtin/commit-tree.o
948 BUILTIN_OBJS += builtin/commit.o
949 +BUILTIN_OBJS += builtin/commit-graph.o
950 BUILTIN_OBJS += builtin/config.o
951 BUILTIN_OBJS += builtin/count-objects.o
952 BUILTIN_OBJS += builtin/credential.o
builtin.h
+1
@@ -149,6 +149,7 @@ extern int cmd_clone(int argc, const char **argv, const char *prefix);
149 extern int cmd_clean(int argc, const char **argv, const char *prefix);
150 extern int cmd_column(int argc, const char **argv, const char *prefix);
151 extern int cmd_commit(int argc, const char **argv, const char *prefix);
152 +extern int cmd_commit_graph(int argc, const char **argv, const char *prefix);
153 extern int cmd_commit_tree(int argc, const char **argv, const char *prefix);
154 extern int cmd_config(int argc, const char **argv, const char *prefix);
155 extern int cmd_count_objects(int argc, const char **argv, const char *prefix);
builtin/commit-graph.c new
+36
@@ -0,0 +1,36 @@
1 +#include "builtin.h"
2 +#include "config.h"
3 +#include "parse-options.h"
4 +
5 +static char const * const builtin_commit_graph_usage[] = {
6 + N_("git commit-graph [--object-dir <objdir>]"),
7 + NULL
8 +};
9 +
10 +static struct opts_commit_graph {
11 + const char *obj_dir;
12 +} opts;
13 +
14 +
15 +int cmd_commit_graph(int argc, const char **argv, const char *prefix)
16 +{
17 + static struct option builtin_commit_graph_options[] = {
18 + OPT_STRING(0, "object-dir", &opts.obj_dir,
19 + N_("dir"),
20 + N_("The object directory to store the graph")),
21 + OPT_END(),
22 + };
23 +
24 + if (argc == 2 && !strcmp(argv[1], "-h"))
25 + usage_with_options(builtin_commit_graph_usage,
26 + builtin_commit_graph_options);
27 +
28 + git_config(git_default_config, NULL);
29 + argc = parse_options(argc, argv, prefix,
30 + builtin_commit_graph_options,
31 + builtin_commit_graph_usage,
32 + PARSE_OPT_STOP_AT_NON_OPTION);
33 +
34 + usage_with_options(builtin_commit_graph_usage,
35 + builtin_commit_graph_options);
36 +}
command-list.txt
+1
@@ -34,6 +34,7 @@ git-clean mainporcelain
34 git-clone mainporcelain init
35 git-column purehelpers
36 git-commit mainporcelain history
37 +git-commit-graph plumbingmanipulators
38 git-commit-tree plumbingmanipulators
39 git-config ancillarymanipulators
40 git-count-objects ancillaryinterrogators
contrib/completion/git-completion.bash
+2
@@ -841,6 +841,7 @@ __git_list_porcelain_commands ()
841 check-ref-format) : plumbing;;
842 checkout-index) : plumbing;;
843 column) : internal helper;;
844 + commit-graph) : plumbing;;
845 commit-tree) : plumbing;;
846 count-objects) : infrequent;;
847 credential) : credentials;;
@@ -2419,6 +2420,7 @@ _git_config ()
2420 core.bigFileThreshold
2421 core.checkStat
2422 core.commentChar
2423 + core.commitGraph
2424 core.compression
2425 core.createObject
2426 core.deltaBaseCacheLimit
git.c
+1
@@ -388,6 +388,7 @@ static struct cmd_struct commands[] = {
388 { "clone", cmd_clone },
389 { "column", cmd_column, RUN_SETUP_GENTLY },
390 { "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
391 + { "commit-graph", cmd_commit_graph, RUN_SETUP },
392 { "commit-tree", cmd_commit_tree, RUN_SETUP },
393 { "config", cmd_config, RUN_SETUP_GENTLY },
394 { "count-objects", cmd_count_objects, RUN_SETUP },