Skip to content

Commit 4ce58ee

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ae30d7b commit 4ce58ee

File tree

8 files changed

+53
-0
lines changed

8 files changed

+53
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
/git-clone
3535
/git-column
3636
/git-commit
37+
/git-commit-graph
3738
/git-commit-tree
3839
/git-config
3940
/git-count-objects

Documentation/git-commit-graph.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,7 @@ BUILTIN_OBJS += builtin/clone.o
946946
BUILTIN_OBJS += builtin/column.o
947947
BUILTIN_OBJS += builtin/commit-tree.o
948948
BUILTIN_OBJS += builtin/commit.o
949+
BUILTIN_OBJS += builtin/commit-graph.o
949950
BUILTIN_OBJS += builtin/config.o
950951
BUILTIN_OBJS += builtin/count-objects.o
951952
BUILTIN_OBJS += builtin/credential.o

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ extern int cmd_clone(int argc, const char **argv, const char *prefix);
149149
extern int cmd_clean(int argc, const char **argv, const char *prefix);
150150
extern int cmd_column(int argc, const char **argv, const char *prefix);
151151
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);
152153
extern int cmd_commit_tree(int argc, const char **argv, const char *prefix);
153154
extern int cmd_config(int argc, const char **argv, const char *prefix);
154155
extern int cmd_count_objects(int argc, const char **argv, const char *prefix);

builtin/commit-graph.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ git-clean mainporcelain
3434
git-clone mainporcelain init
3535
git-column purehelpers
3636
git-commit mainporcelain history
37+
git-commit-graph plumbingmanipulators
3738
git-commit-tree plumbingmanipulators
3839
git-config ancillarymanipulators
3940
git-count-objects ancillaryinterrogators

contrib/completion/git-completion.bash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ __git_list_porcelain_commands ()
841841
check-ref-format) : plumbing;;
842842
checkout-index) : plumbing;;
843843
column) : internal helper;;
844+
commit-graph) : plumbing;;
844845
commit-tree) : plumbing;;
845846
count-objects) : infrequent;;
846847
credential) : credentials;;
@@ -2419,6 +2420,7 @@ _git_config ()
24192420
core.bigFileThreshold
24202421
core.checkStat
24212422
core.commentChar
2423+
core.commitGraph
24222424
core.compression
24232425
core.createObject
24242426
core.deltaBaseCacheLimit

git.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ static struct cmd_struct commands[] = {
388388
{ "clone", cmd_clone },
389389
{ "column", cmd_column, RUN_SETUP_GENTLY },
390390
{ "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
391+
{ "commit-graph", cmd_commit_graph, RUN_SETUP },
391392
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
392393
{ "config", cmd_config, RUN_SETUP_GENTLY },
393394
{ "count-objects", cmd_count_objects, RUN_SETUP },

0 commit comments

Comments
 (0)