Re: [PATCH 14/18] fsck: allow upgrading fsck warnings to errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin <johannes.schindelin@xxxxxx> writes:

> The 'invalid tag name' and 'missing tagger entry' warnings can now be
> upgraded to errors by setting receive.fsck.invalid-tag-name and
> receive.fsck.missing-tagger-entry to 'error'.

Hmm, why can't all warnings promotable to errors, or are the above
two mentioned only as examples?

>
> Incidentally, the missing tagger warning is now really shown as a warning
> (as opposed to being reported with the "error:" prefix, as it used to be
> the case before this commit).
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
> ---
>  fsck.c                | 24 ++++++++++++++++--------
>  t/t5302-pack-index.sh |  2 +-
>  2 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/fsck.c b/fsck.c
> index abfd3af..154f361 100644
> --- a/fsck.c
> +++ b/fsck.c
> @@ -52,13 +52,15 @@
>  	FUNC(HAS_DOT) \
>  	FUNC(HAS_DOTDOT) \
>  	FUNC(HAS_DOTGIT) \
> -	FUNC(INVALID_TAG_NAME) \
> -	FUNC(MISSING_TAGGER_ENTRY) \
>  	FUNC(NULL_SHA1) \
> -	FUNC(ZERO_PADDED_FILEMODE)
> +	FUNC(ZERO_PADDED_FILEMODE) \
> +	/* infos (reported as warnings, but ignored by default) */ \
> +	FUNC(INVALID_TAG_NAME) \
> +	FUNC(MISSING_TAGGER_ENTRY)
>  
>  #define FIRST_NON_FATAL_ERROR FSCK_MSG_BAD_DATE
>  #define FIRST_WARNING FSCK_MSG_BAD_FILEMODE
> +#define FIRST_INFO FSCK_MSG_INVALID_TAG_NAME
>  
>  #define MSG_ID(x) FSCK_MSG_##x,
>  enum fsck_msg_id {
> @@ -103,7 +105,7 @@ int fsck_msg_type(enum fsck_msg_id msg_id, struct fsck_options *options)
>  	if (options->strict_mode && msg_id >= 0 && msg_id < FSCK_MSG_MAX)
>  		return options->strict_mode[msg_id];
>  	if (options->strict)
> -		return FSCK_ERROR;
> +		return msg_id < FIRST_INFO ? FSCK_ERROR : FSCK_WARN;
>  	return msg_id < FIRST_WARNING ? FSCK_ERROR : FSCK_WARN;
>  }
>  
> @@ -643,13 +645,19 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,
>  		goto done;
>  	}
>  	strbuf_addf(&sb, "refs/tags/%.*s", (int)(eol - buffer), buffer);
> -	if (check_refname_format(sb.buf, 0))
> -		report(options, &tag->object, FSCK_MSG_INVALID_TAG_NAME, "invalid 'tag' name: %s", buffer);
> +	if (check_refname_format(sb.buf, 0)) {
> +		ret = report(options, &tag->object, FSCK_MSG_INVALID_TAG_NAME, "invalid 'tag' name: %s", buffer);
> +		if (ret)
> +			goto done;
> +	}
>  	buffer = eol + 1;
>  
> -	if (!skip_prefix(buffer, "tagger ", &buffer))
> +	if (!skip_prefix(buffer, "tagger ", &buffer)) {
>  		/* early tags do not contain 'tagger' lines; warn only */
> -		report(options, &tag->object, FSCK_MSG_MISSING_TAGGER_ENTRY, "invalid format - expected 'tagger' line");
> +		ret = report(options, &tag->object, FSCK_MSG_MISSING_TAGGER_ENTRY, "invalid format - expected 'tagger' line");
> +		if (ret)
> +			goto done;
> +	}
>  	else
>  		ret = fsck_ident(&buffer, &tag->object, options);
>  
> diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh
> index 61bc8da..3dc5ec4 100755
> --- a/t/t5302-pack-index.sh
> +++ b/t/t5302-pack-index.sh
> @@ -259,7 +259,7 @@ EOF
>      thirtyeight=${tag#??} &&
>      rm -f .git/objects/${tag%$thirtyeight}/$thirtyeight &&
>      git index-pack --strict tag-test-${pack1}.pack 2>err &&
> -    grep "^error:.* expected .tagger. line" err
> +    grep "^warning:.* expected .tagger. line" err
>  '
>  
>  test_done
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]