Subject: Re: [PATCH 7/9] fsck: consider gpgsig headers expected in tags

From: Junio C Hamano <[email-masked]>
Date: Fri, 19 Sep 2025 16:31:08 -0700

"brian m. carlson" <[email-masked]> writes:

> diff --git a/fsck.c b/fsck.c
> index 171b424dd5..341e100d24 100644
> --- a/fsck.c
> +++ b/fsck.c
> @@ -1067,6 +1067,24 @@ int fsck_tag_standalone(const struct object_id *oid, const char *buffer,
>  	else
>  		ret = fsck_ident(&buffer, oid, OBJ_TAG, options);
>  
> +	if (buffer < buffer_end && (skip_prefix(buffer, "gpgsig ", &buffer) || skip_prefix(buffer, "gpgsig-sha256 ", &buffer))) {

Could you wrap this overly long line?

	if (buffer < buffer_end && 
	    (skip_prefix(buffer, "gpgsig ", &buffer) ||
	     skip_prefix(buffer, "gpgsig-sha256 ", &buffer))) {

> +		eol = memchr(buffer, '\n', buffer_end - buffer);
> +		if (!eol) {
> +			ret = report(options, oid, OBJ_TAG, FSCK_MSG_BAD_GPGSIG, "invalid format - unexpected end after 'gpgsig' or 'gpgsig-sha256' line");
> +			goto done;
> +		}
> +		buffer = eol + 1;
> +
> +		while (buffer < buffer_end && starts_with(buffer, " ")) {
> +			eol = memchr(buffer, '\n', buffer_end - buffer);
> +			if (!eol) {
> +				ret = report(options, oid, OBJ_TAG, FSCK_MSG_BAD_HEADER_CONTINUATION, "invalid format - unexpected end in 'gpgsig' or 'gpgsig-sha256' continuation line");
> +				goto done;
> +			}
> +			buffer = eol + 1;
> +		}
> +	}
> +

Do we allow a tag object with both "gpgsig" and "gpgsig-sha256" or
detect as an error?  I think the most natural way to extend this
system in the future with a third hash function would be to still
have the primary hash in the payload and signatures created with
other compatibility hash functions on the header, so if we were to
detect, the rule may be "gpgsig* in the headers ought to be unique
and should not include the primary hash algorithm" plus "if you have
gpgsig* in the header, the body must also have inline signature, and
if you don't, the body must not", perhaps?