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

From: Junio C Hamano <[email-masked]>
Date: Wed, 10 Dec 2014 10:06:51 -0800

Johannes Schindelin <[email-masked]> writes:

> 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.

Makes sense, but the patch makes it look as if this is an "oops, we
should have done the list in patch 02/18 in this order from the
beginning".  Can we reorder the patches?

>
> Signed-off-by: Johannes Schindelin <[email-masked]>
> ---
>  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