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-05 22:42:48 +0300
committerJunio C Hamano <gitster@pobox.com>2021-01-06 01:58:29 +0300
commitacfc01332bc477e19b8af6b5002c0b962fde3326 (patch)
tree2cecf36cb27903de43281bc2c44db4dfea80cec5 /builtin/mktag.c
parent1f3299fda9d0800d8e882540d36e4d78797e998e (diff)
mktag: allow turning off fsck.extraHeaderEntry
In earlier commits mktag learned to use the fsck machinery, at which point we needed to add fsck.extraHeaderEntry so it could be as strict about extra headers as it's been ever since it was implemented. But it's not nice to need to switch away from "mktag" to "hash-object" + manual "fsck" just because you'd like to have an extra header. So let's support turning it off by getting "fsck.*" variables from the config. Pedantically speaking it's still not possible to make "mktag" behave just like "hash-object -t tag" does, since we're unconditionally going to check the referenced object in verify_object_in_tag(), which is our own check, and not one that exists in fsck.c. But the spirit of "this works like fsck" is preserved, in that if you created such a tag with "hash-object" and did a full "fsck" on the repository it would also error out about that invalid object, it just wouldn't emit the same message as fsck does. 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.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 4dd35bc79e..373926d7e0 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -3,6 +3,14 @@
#include "replace-object.h"
#include "object-store.h"
#include "fsck.h"
+#include "config.h"
+
+static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
+
+static int mktag_config(const char *var, const char *value, void *cb)
+{
+ return fsck_config_internal(var, value, cb, &fsck_options);
+}
static int mktag_fsck_error_func(struct fsck_options *o,
const struct object_id *oid,
@@ -53,7 +61,6 @@ 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)
{
struct strbuf buf = STRBUF_INIT;
- struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
struct object_id tagged_oid;
int tagged_type;
struct object_id result;
@@ -66,6 +73,8 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)
fsck_options.error_func = mktag_fsck_error_func;
fsck_set_msg_type(&fsck_options, "extraheaderentry", "warn");
+ /* config might set fsck.extraHeaderEntry=* again */
+ git_config(mktag_config, NULL);
if (fsck_tag_standalone(NULL, buf.buf, buf.len, &fsck_options,
&tagged_oid, &tagged_type))
die("tag on stdin did not pass our strict fsck check");