Some kinds of errors are intrinsically unrecoverable (e.g. errors while
uncompressing objects). It does not make sense to allow demoting them to
mere warnings.

Signed-off-by: Johannes Schindelin <johannes.schinde...@gmx.de>
---
 fsck.c                          | 13 +++++++++++--
 t/t5504-fetch-receive-strict.sh | 11 +++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/fsck.c b/fsck.c
index f72e404..e126320 100644
--- a/fsck.c
+++ b/fsck.c
@@ -9,7 +9,12 @@
 #include "refs.h"
 #include "utf8.h"
 
+#define FSCK_FATAL -1
+
 #define FOREACH_MSG_ID(FUNC) \
+       /* fatal errors */ \
+       FUNC(NUL_IN_HEADER, FATAL) \
+       FUNC(UNTERMINATED_HEADER, FATAL) \
        /* errors */ \
        FUNC(BAD_DATE, ERROR) \
        FUNC(BAD_EMAIL, ERROR) \
@@ -40,10 +45,8 @@
        FUNC(MISSING_TYPE_ENTRY, ERROR) \
        FUNC(MULTIPLE_AUTHORS, ERROR) \
        FUNC(NOT_SORTED, ERROR) \
-       FUNC(NUL_IN_HEADER, ERROR) \
        FUNC(TAG_OBJECT_NOT_TAG, ERROR) \
        FUNC(UNKNOWN_TYPE, ERROR) \
-       FUNC(UNTERMINATED_HEADER, ERROR) \
        FUNC(ZERO_PADDED_DATE, ERROR) \
        /* warnings */ \
        FUNC(BAD_FILEMODE, WARN) \
@@ -163,6 +166,9 @@ void fsck_set_severity(struct fsck_options *options, const 
char *mode)
                                        len2, p);
                }
 
+               if (severity != FSCK_ERROR &&
+                               msg_id_info[msg_id].severity == FSCK_FATAL)
+                       die("Cannot demote %.*s", len, mode);
                options->msg_severity[msg_id] = severity;
                mode += len;
        }
@@ -193,6 +199,9 @@ static int report(struct fsck_options *options, struct 
object *object,
        struct strbuf sb = STRBUF_INIT;
        int msg_severity = fsck_msg_severity(id, options), result;
 
+       if (msg_severity == FSCK_FATAL)
+               msg_severity = FSCK_ERROR;
+
        append_msg_id(&sb, msg_id_info[id].id_string);
 
        va_start(ap, fmt);
diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh
index 9d49cb7..0b6af82 100755
--- a/t/t5504-fetch-receive-strict.sh
+++ b/t/t5504-fetch-receive-strict.sh
@@ -136,4 +136,15 @@ test_expect_success 'push with receive.fsck.severity = 
missing-email=warn' '
        grep "missing-email" act
 '
 
+test_expect_success \
+       'receive.fsck.severity = unterminated-header=warn triggers error' '
+       rm -rf dst &&
+       git init dst &&
+       git --git-dir=dst/.git config receive.fsckobjects true &&
+       git --git-dir=dst/.git config \
+               receive.fsck.severity unterminated-header=warn &&
+       test_must_fail git push --porcelain dst HEAD >act 2>&1 &&
+       grep "Cannot demote unterminated-header" act
+'
+
 test_done
-- 
2.2.0.33.gc18b867



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to