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

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-01-06 14:47:27 +0300
committerJunio C Hamano <gitster@pobox.com>2021-01-07 01:22:24 +0300
commit06ce79152be8dab44b63faf4486d5c5c171434af (patch)
treee50a9b8420d480cd1fd6180dee94c9016335e972 /builtin/mktag.c
parent2aa9425fbeb58f459240f223525e512499ab62e4 (diff)
mktag: add a --[no-]strict option
Now that mktag has been migrated to use the fsck machinery to check its input, it makes sense to teach it to run in the equivalent of "git fsck"'s default mode. For cases where mktag is used to (re)create a tag object using data from an existing and malformed tag object, the validation may optionally have to be loosened. Teach the command to take the "--[no-]strict" option to do so. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/mktag.c')
-rw-r--r--builtin/mktag.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 9b04b61c2b..41a399a69e 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -10,6 +10,7 @@ static char const * const builtin_mktag_usage[] = {
N_("git mktag"),
NULL
};
+static int option_strict = 1;
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
@@ -25,6 +26,12 @@ static int mktag_fsck_error_func(struct fsck_options *o,
{
switch (msg_type) {
case FSCK_WARN:
+ if (!option_strict) {
+ fprintf_ln(stderr, _("warning: tag input does not pass fsck: %s"), message);
+ return 0;
+
+ }
+ /* fallthrough */
case FSCK_ERROR:
/*
* We treat both warnings and errors as errors, things
@@ -67,6 +74,8 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
int cmd_mktag(int argc, const char **argv, const char *prefix)
{
static struct option builtin_mktag_options[] = {
+ OPT_BOOL(0, "strict", &option_strict,
+ N_("enable more strict checking")),
OPT_END(),
};
struct strbuf buf = STRBUF_INIT;