diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-01-06 12:47:27 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-01-06 14:22:24 -0800 |
commit | 06ce79152be8dab44b63faf4486d5c5c171434af (patch) | |
tree | e50a9b8420d480cd1fd6180dee94c9016335e972 /builtin/mktag.c | |
parent | mktag: mark strings for translation (diff) | |
download | tgif-06ce79152be8dab44b63faf4486d5c5c171434af.tar.xz |
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.c | 9 |
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; |