Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-05-01 23:39:52 +0300
committerJunio C Hamano <gitster@pobox.com>2020-05-01 23:39:52 +0300
commit6a1c17d05b0e67fa5f9661f492f407b984496b27 (patch)
tree2abe4b8ae7cb8eb78e93ca07cd1e9426a876297d /builtin/commit-graph.c
parent2b4ff3d3dc64d4abcded7caa9bcdf063aea5ec3f (diff)
parentdbd5e0a1861c5bb1446e5518173aa1760c6617b0 (diff)
Merge branch 'tb/commit-graph-split-strategy'
"git commit-graph write" learned different ways to write out split files. * tb/commit-graph-split-strategy: Revert "commit-graph.c: introduce '--[no-]check-oids'" commit-graph.c: introduce '--[no-]check-oids' commit-graph.h: replace 'commit_hex' with 'commits' oidset: introduce 'oidset_size' builtin/commit-graph.c: introduce split strategy 'replace' builtin/commit-graph.c: introduce split strategy 'no-merge' builtin/commit-graph.c: support for '--split[=<strategy>]' t/helper/test-read-graph.c: support commit-graph chains
Diffstat (limited to 'builtin/commit-graph.c')
-rw-r--r--builtin/commit-graph.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 03a8331e2b6..9ceedbba074 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -9,7 +9,9 @@
static char const * const builtin_commit_graph_usage[] = {
N_("git commit-graph verify [--object-dir <objdir>] [--shallow] [--[no-]progress]"),
- N_("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--[no-]progress] <split options>"),
+ N_("git commit-graph write [--object-dir <objdir>] [--append] "
+ "[--split[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] "
+ "[--[no-]progress] <split options>"),
NULL
};
@@ -19,7 +21,9 @@ static const char * const builtin_commit_graph_verify_usage[] = {
};
static const char * const builtin_commit_graph_write_usage[] = {
- N_("git commit-graph write [--object-dir <objdir>] [--append|--split] [--reachable|--stdin-packs|--stdin-commits] [--[no-]progress] <split options>"),
+ N_("git commit-graph write [--object-dir <objdir>] [--append] "
+ "[--split[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] "
+ "[--[no-]progress] <split options>"),
NULL
};
@@ -114,10 +118,29 @@ static int graph_verify(int argc, const char **argv)
extern int read_replace_refs;
static struct split_commit_graph_opts split_opts;
+static int write_option_parse_split(const struct option *opt, const char *arg,
+ int unset)
+{
+ enum commit_graph_split_flags *flags = opt->value;
+
+ opts.split = 1;
+ if (!arg)
+ return 0;
+
+ if (!strcmp(arg, "no-merge"))
+ *flags = COMMIT_GRAPH_SPLIT_MERGE_PROHIBITED;
+ else if (!strcmp(arg, "replace"))
+ *flags = COMMIT_GRAPH_SPLIT_REPLACE;
+ else
+ die(_("unrecognized --split argument, %s"), arg);
+
+ return 0;
+}
+
static int graph_write(int argc, const char **argv)
{
struct string_list *pack_indexes = NULL;
- struct string_list *commit_hex = NULL;
+ struct oidset commits = OIDSET_INIT;
struct object_directory *odb = NULL;
struct string_list lines;
int result = 0;
@@ -136,8 +159,10 @@ static int graph_write(int argc, const char **argv)
OPT_BOOL(0, "append", &opts.append,
N_("include all commits already in the commit-graph file")),
OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
- OPT_BOOL(0, "split", &opts.split,
- N_("allow writing an incremental commit-graph file")),
+ OPT_CALLBACK_F(0, "split", &split_opts.flags, NULL,
+ N_("allow writing an incremental commit-graph file"),
+ PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
+ write_option_parse_split),
OPT_INTEGER(0, "max-commits", &split_opts.max_commits,
N_("maximum number of commits in a non-base split commit-graph")),
OPT_INTEGER(0, "size-multiple", &split_opts.size_multiple,
@@ -188,7 +213,20 @@ static int graph_write(int argc, const char **argv)
if (opts.stdin_packs)
pack_indexes = &lines;
if (opts.stdin_commits) {
- commit_hex = &lines;
+ struct string_list_item *item;
+ oidset_init(&commits, lines.nr);
+ for_each_string_list_item(item, &lines) {
+ struct object_id oid;
+ const char *end;
+
+ if (parse_oid_hex(item->string, &oid, &end)) {
+ error(_("unexpected non-hex object ID: "
+ "%s"), item->string);
+ return 1;
+ }
+
+ oidset_insert(&commits, &oid);
+ }
flags |= COMMIT_GRAPH_WRITE_CHECK_OIDS;
}
@@ -197,7 +235,7 @@ static int graph_write(int argc, const char **argv)
if (write_commit_graph(odb,
pack_indexes,
- commit_hex,
+ opts.stdin_commits ? &commits : NULL,
flags,
&split_opts))
result = 1;