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:
authorTaylor Blau <me@ttaylorr.com>2020-04-15 07:31:37 +0300
committerJunio C Hamano <gitster@pobox.com>2020-04-15 19:20:34 +0300
commit7a9ce0269bc0f4ef230f930b3910b70ac3142552 (patch)
treee135caeef62e7d138d2e9aee337b25a6de1fec36 /builtin/commit-graph.c
parent6830c360777468434184f60023e2562348c9dacc (diff)
commit-graph.c: introduce '--[no-]check-oids'
When operating on a stream of commit OIDs on stdin, 'git commit-graph write' checks that each OID refers to an object that is indeed a commit. This is convenient to make sure that the given input is well-formed, but can sometimes be undesirable. For example, server operators may wish to feed the refnames that were updated during a push to 'git commit-graph write --input=stdin-commits', and silently discard refs that don't point at commits. This can be done by combing the output of 'git for-each-ref' with '--format %(*objecttype)', but this requires opening up a potentially large number of objects. Instead, it is more convenient to feed the updated refs to the commit-graph machinery, and let it throw out refs that don't point to commits. Introduce '--[no-]check-oids' to make such a behavior possible. With '--check-oids' (the default behavior to retain backwards compatibility), 'git commit-graph write' will barf on a non-commit line in its input. With 'no-check-oids', such lines will be silently ignored, making the above possible by specifying this option. No matter which is supplied, 'git commit-graph write' retains the behavior from the previous commit of rejecting non-OID inputs like "HEAD" and "refs/heads/foo" as before. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit-graph.c')
-rw-r--r--builtin/commit-graph.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 075f8f69283..28571530088 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -11,7 +11,7 @@ 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[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] "
- "[--[no-]progress] <split options>"),
+ "[--[no-]progress] [--[no-]check-oids] <split options>"),
NULL
};
@@ -23,7 +23,7 @@ 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[=<strategy>]] [--reachable|--stdin-packs|--stdin-commits] "
- "[--[no-]progress] <split options>"),
+ "[--[no-]progress] [--[no-]check-oids] <split options>"),
NULL
};
@@ -36,6 +36,7 @@ static struct opts_commit_graph {
int split;
int shallow;
int progress;
+ int check_oids;
} opts;
static struct object_directory *find_odb(struct repository *r,
@@ -160,6 +161,8 @@ static int graph_write(int argc, const char **argv)
N_("allow writing an incremental commit-graph file"),
PARSE_OPT_OPTARG | PARSE_OPT_NONEG,
write_option_parse_split),
+ OPT_BOOL(0, "check-oids", &opts.check_oids,
+ N_("require OIDs to be commits")),
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,
@@ -170,6 +173,7 @@ static int graph_write(int argc, const char **argv)
};
opts.progress = isatty(2);
+ opts.check_oids = 1;
split_opts.size_multiple = 2;
split_opts.max_commits = 0;
split_opts.expire_time = 0;
@@ -224,7 +228,8 @@ static int graph_write(int argc, const char **argv)
oidset_insert(&commits, &oid);
}
- flags |= COMMIT_GRAPH_WRITE_CHECK_OIDS;
+ if (opts.check_oids)
+ flags |= COMMIT_GRAPH_WRITE_CHECK_OIDS;
}
UNLEAK(buf);