Thread (19 messages) 19 messages, 1 author, 2016-06-15

[PATCH 12/18] Disallow demoting grave fsck errors to warnings

flat view
DORMANTno replies

From: Johannes Schindelin <hidden>
Date: 2016-06-15 23:03:14
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 fsck.c                          | 8 ++++++--
 t/t5504-fetch-receive-strict.sh | 9 +++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/fsck.c b/fsck.c
index c1e7a85..f8339af 100644
--- a/fsck.c
+++ b/fsck.c
@@ -9,6 +9,9 @@
 #include "refs.h"
 
 #define FOREACH_MSG_ID(FUNC) \
+	/* fatal errors */ \
+	FUNC(NUL_IN_HEADER) \
+	FUNC(UNTERMINATED_HEADER) \
 	/* errors */ \
 	FUNC(BAD_DATE) \
 	FUNC(BAD_EMAIL) \
@@ -39,10 +42,8 @@
 	FUNC(MISSING_TYPE_ENTRY) \
 	FUNC(MULTIPLE_AUTHORS) \
 	FUNC(NOT_SORTED) \
-	FUNC(NUL_IN_HEADER) \
 	FUNC(TAG_OBJECT_NOT_TAG) \
 	FUNC(UNKNOWN_TYPE) \
-	FUNC(UNTERMINATED_HEADER) \
 	FUNC(ZERO_PADDED_DATE) \
 	/* warnings */ \
 	FUNC(BAD_FILEMODE) \
@@ -56,6 +57,7 @@
 	FUNC(NULL_SHA1) \
 	FUNC(ZERO_PADDED_FILEMODE)
 
+#define FIRST_NON_FATAL_ERROR FSCK_MSG_BAD_DATE
 #define FIRST_WARNING FSCK_MSG_BAD_FILEMODE
 
 #define MSG_ID(x) FSCK_MSG_##x,
@@ -150,6 +152,8 @@ void fsck_strict_mode(struct fsck_options *options, const char *mode)
 		}
 
 		msg_id = parse_msg_id(mode, equal);
+		if (type != FSCK_ERROR && msg_id < FIRST_NON_FATAL_ERROR)
+			die("Cannot demote %.*s", len, mode);
 		options->strict_mode[msg_id] = type;
 		mode += len;
 	}
diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh
index db79e56..8a47db2 100755
--- a/t/t5504-fetch-receive-strict.sh
+++ b/t/t5504-fetch-receive-strict.sh
@@ -135,4 +135,13 @@ test_expect_success 'push with receive.fsck.missing-mail = warn' '
 	grep "missing-email" act
 '
 
+test_expect_success 'receive.fsck.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.unterminated-header warn &&
+	test_must_fail git push --porcelain dst HEAD >act 2>&1 &&
+	grep "Cannot demote unterminated-header=warn" act
+'
+
 test_done
-- 
2.0.0.rc3.9669.g840d1f9
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help