aboutsummaryrefslogtreecommitdiff
path: root/fsck.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2015-06-22 17:26:42 +0200
committerJunio C Hamano <gitster@pobox.com>2015-06-23 14:27:36 -0700
commitf50c44073051820cd368be4ca520ae43f34fdf8b (patch)
tree6014b05cb8c796451fb8a5e5dac59dedeb3c86bf /fsck.c
parent70a4ae73d8a6d8d0ce86d746a20bb243d83d28e3 (diff)
downloadgit-f50c44073051820cd368be4ca520ae43f34fdf8b.tar.gz
git-f50c44073051820cd368be4ca520ae43f34fdf8b.tar.xz
fsck: disallow demoting grave fsck errors to warnings
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.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fsck.c b/fsck.c
index 6635e15b1..a4205aaa5 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_DATE_OVERFLOW, ERROR) \
@@ -39,11 +44,9 @@
FUNC(MISSING_TYPE, ERROR) \
FUNC(MISSING_TYPE_ENTRY, ERROR) \
FUNC(MULTIPLE_AUTHORS, ERROR) \
- FUNC(NUL_IN_HEADER, ERROR) \
FUNC(TAG_OBJECT_NOT_TAG, ERROR) \
FUNC(TREE_NOT_SORTED, ERROR) \
FUNC(UNKNOWN_TYPE, ERROR) \
- FUNC(UNTERMINATED_HEADER, ERROR) \
FUNC(ZERO_PADDED_DATE, ERROR) \
/* warnings */ \
FUNC(BAD_FILEMODE, WARN) \
@@ -149,6 +152,9 @@ void fsck_set_msg_type(struct fsck_options *options,
die("Unhandled message id: %s", msg_id);
type = parse_msg_type(msg_type);
+ if (type != FSCK_ERROR && msg_id_info[id].msg_type == FSCK_FATAL)
+ die("Cannot demote %s to %s", msg_id, msg_type);
+
if (!options->msg_type) {
int i;
int *msg_type = xmalloc(sizeof(int) * FSCK_MSG_MAX);
@@ -216,6 +222,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;
+ if (msg_type == FSCK_FATAL)
+ msg_type = FSCK_ERROR;
+
append_msg_id(&sb, msg_id_info[id].id_string);
va_start(ap, fmt);