fsck: optionally ignore specific fsck issues completely
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 22 Jun 2015 15:26:48 +0000 (17:26 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Jun 2015 21:27:36 +0000 (14:27 -0700)
An fsck issue in a legacy repository might be so common that one would
like not to bother the user with mentioning it at all. With this change,
that is possible by setting the respective message type to "ignore".

This change "abuses" the missingEmail=warn test to verify that "ignore"
is also accepted and works correctly. And while at it, it makes sure
that multiple options work, too (they are passed to unpack-objects or
index-pack as a comma-separated list via the --strict=... command-line
option).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fsck.c
fsck.h
t/t5504-fetch-receive-strict.sh
diff --git a/fsck.c b/fsck.c
index a4205aaa5fe4f0b36a14d4377e505447890b45de..680f35eff0eca657af4aeb33caa496efcf6319af 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -131,6 +131,8 @@ static int parse_msg_type(const char *str)
                return FSCK_ERROR;
        else if (!strcmp(str, "warn"))
                return FSCK_WARN;
                return FSCK_ERROR;
        else if (!strcmp(str, "warn"))
                return FSCK_WARN;
+       else if (!strcmp(str, "ignore"))
+               return FSCK_IGNORE;
        else
                die("Unknown fsck message type: '%s'", str);
 }
        else
                die("Unknown fsck message type: '%s'", str);
 }
@@ -222,6 +224,9 @@ static int report(struct fsck_options *options, struct object *object,
        struct strbuf sb = STRBUF_INIT;
        int msg_type = fsck_msg_type(id, options), result;
 
        struct strbuf sb = STRBUF_INIT;
        int msg_type = fsck_msg_type(id, options), result;
 
+       if (msg_type == FSCK_IGNORE)
+               return 0;
+
        if (msg_type == FSCK_FATAL)
                msg_type = FSCK_ERROR;
 
        if (msg_type == FSCK_FATAL)
                msg_type = FSCK_ERROR;
 
diff --git a/fsck.h b/fsck.h
index 3ef92a31a6df87edd2682459dceb77424c417f20..1dab276899c09aafc0ccfa249b5093271ec6a414 100644 (file)
--- a/fsck.h
+++ b/fsck.h
@@ -3,6 +3,7 @@
 
 #define FSCK_ERROR 1
 #define FSCK_WARN 2
 
 #define FSCK_ERROR 1
 #define FSCK_WARN 2
+#define FSCK_IGNORE 3
 
 struct fsck_options;
 
 
 struct fsck_options;
 
index f5d6d0ded062f37b814663f91d8de22859dbe5ae..720c1215224009afac856ea10be6ae153c27d1ce 100755 (executable)
@@ -133,7 +133,14 @@ test_expect_success 'push with receive.fsck.missingEmail=warn' '
        git --git-dir=dst/.git config \
                receive.fsck.missingEmail warn &&
        git push --porcelain dst bogus >act 2>&1 &&
        git --git-dir=dst/.git config \
                receive.fsck.missingEmail warn &&
        git push --porcelain dst bogus >act 2>&1 &&
-       grep "missingEmail" act
+       grep "missingEmail" act &&
+       git --git-dir=dst/.git branch -D bogus &&
+       git --git-dir=dst/.git config --add \
+               receive.fsck.missingEmail ignore &&
+       git --git-dir=dst/.git config --add \
+               receive.fsck.badDate warn &&
+       git push --porcelain dst bogus >act 2>&1 &&
+       test_must_fail grep "missingEmail" act
 '
 
 test_expect_success \
 '
 
 test_expect_success \