Re: [PATCH v6 06/19] fsck: Report the ID of the error/warning

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

 



Johannes Schindelin <johannes.schindelin@xxxxxx> writes:

> Some legacy code has objects with non-fatal fsck issues; To enable the
> user to ignore those issues, let's print out the ID (e.g. when
> encountering "missingemail", the user might want to call `git config
> --add receive.fsck.missingemail=warn`).
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
> ---
>  fsck.c          | 16 ++++++++++++++++
>  t/t1450-fsck.sh |  4 ++--
>  2 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/fsck.c b/fsck.c
> index 8e6faa8..0b3e18f 100644
> --- a/fsck.c
> +++ b/fsck.c
> @@ -190,6 +190,20 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values)
>  	}
>  }
>  
> +static void append_msg_id(struct strbuf *sb, const char *msg_id)
> +{
> +	for (;;) {
> +		char c = *(msg_id)++;
> +
> +		if (!c)
> +			break;
> +		if (c != '_')
> +			strbuf_addch(sb, tolower(c));
> +	}
> +
> +	strbuf_addstr(sb, ": ");
> +}
> +
>  __attribute__((format (printf, 4, 5)))
>  static int report(struct fsck_options *options, struct object *object,
>  	enum fsck_msg_id id, const char *fmt, ...)
> @@ -198,6 +212,8 @@ static int report(struct fsck_options *options, struct object *object,
>  	struct strbuf sb = STRBUF_INIT;
>  	int msg_type = fsck_msg_type(id, options), result;
>  
> +	append_msg_id(&sb, msg_id_info[id].id_string);


Nice.  The append function can be made a bit more context sensitive
to upcase a char immediately after _ to make it easier to cut and
paste into "git config" and keep the result readable, I think.

	git config --add receive.fsck.missingEmail=warn

>  	va_start(ap, fmt);
>  	strbuf_vaddf(&sb, fmt, ap);
>  	result = options->error_func(object, msg_type, sb.buf);
> diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
> index cfb32b6..d6d3b13 100755
> --- a/t/t1450-fsck.sh
> +++ b/t/t1450-fsck.sh
> @@ -231,8 +231,8 @@ test_expect_success 'tag with incorrect tag name & missing tagger' '
>  	git fsck --tags 2>out &&
>  
>  	cat >expect <<-EOF &&
> -	warning in tag $tag: invalid '\''tag'\'' name: wrong name format
> -	warning in tag $tag: invalid format - expected '\''tagger'\'' line
> +	warning in tag $tag: badtagname: invalid '\''tag'\'' name: wrong name format
> +	warning in tag $tag: missingtaggerentry: invalid format - expected '\''tagger'\'' line
>  	EOF
>  	test_cmp expect out
>  '
--
To unsubscribe from this list: send the line "unsubscribe git" in



[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]