summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2018-04-10 12:56:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-11 01:43:02 (GMT)
commit049d51a2bb9a03d2f2c2cce1ae41e57dbbf42244 (patch)
treed0bfac6465a31845070c4c55d6916dd6997e94c8 /builtin
parent177722b344256b84f1c97b7363d3f19c04928039 (diff)
downloadgit-049d51a2bb9a03d2f2c2cce1ae41e57dbbf42244.zip
git-049d51a2bb9a03d2f2c2cce1ae41e57dbbf42244.tar.gz
git-049d51a2bb9a03d2f2c2cce1ae41e57dbbf42244.tar.bz2
commit-graph: read only from specific pack-indexes
Teach git-commit-graph to inspect the objects only in a certain list of pack-indexes within the given pack directory. This allows updating the commit graph iteratively. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/commit-graph.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index efd3933..5c70199 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -8,7 +8,7 @@
static char const * const builtin_commit_graph_usage[] = {
N_("git commit-graph [--object-dir <objdir>]"),
N_("git commit-graph read [--object-dir <objdir>]"),
- N_("git commit-graph write [--object-dir <objdir>]"),
+ N_("git commit-graph write [--object-dir <objdir>] [--stdin-packs]"),
NULL
};
@@ -18,12 +18,13 @@ static const char * const builtin_commit_graph_read_usage[] = {
};
static const char * const builtin_commit_graph_write_usage[] = {
- N_("git commit-graph write [--object-dir <objdir>]"),
+ N_("git commit-graph write [--object-dir <objdir>] [--stdin-packs]"),
NULL
};
static struct opts_commit_graph {
const char *obj_dir;
+ int stdin_packs;
} opts;
static int graph_read(int argc, const char **argv)
@@ -76,10 +77,18 @@ static int graph_read(int argc, const char **argv)
static int graph_write(int argc, const char **argv)
{
+ const char **pack_indexes = NULL;
+ int packs_nr = 0;
+ const char **lines = NULL;
+ int lines_nr = 0;
+ int lines_alloc = 0;
+
static struct option builtin_commit_graph_write_options[] = {
OPT_STRING(0, "object-dir", &opts.obj_dir,
N_("dir"),
N_("The object directory to store the graph")),
+ OPT_BOOL(0, "stdin-packs", &opts.stdin_packs,
+ N_("scan pack-indexes listed by stdin for commits")),
OPT_END(),
};
@@ -90,7 +99,25 @@ static int graph_write(int argc, const char **argv)
if (!opts.obj_dir)
opts.obj_dir = get_object_directory();
- write_commit_graph(opts.obj_dir);
+ if (opts.stdin_packs) {
+ struct strbuf buf = STRBUF_INIT;
+ lines_nr = 0;
+ lines_alloc = 128;
+ ALLOC_ARRAY(lines, lines_alloc);
+
+ while (strbuf_getline(&buf, stdin) != EOF) {
+ ALLOC_GROW(lines, lines_nr + 1, lines_alloc);
+ lines[lines_nr++] = strbuf_detach(&buf, NULL);
+ }
+
+ pack_indexes = lines;
+ packs_nr = lines_nr;
+ }
+
+ write_commit_graph(opts.obj_dir,
+ pack_indexes,
+ packs_nr);
+
return 0;
}