Re: [PATCH v2 18/24] gpg-interface: improve interface for parsing tags
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 39 quoted lines
> We have a function which parses a buffer with a signature at the end,
> parse_signature, and this function is used for signed tags. However,
> the transition plan has SHA-256 tags using a header, which is a
> materially different syntax. The current interface is not suitable for
> parsing such tags.
>
> Adjust the parse_signature interface to store the parsed data in two
> strbufs and turn the existing function into parse_signed_buffer. The
> latter is still used in places where we want to strip off the signature
> in a SHA-1 tag or in places where we know we always have a signed
> buffer, such as push certs.
>
> Adjust all the callers to deal with this new interface.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> builtin/fmt-merge-msg.c | 26 ++++++++++++++++++--------
> builtin/receive-pack.c | 4 ++--
> builtin/tag.c | 16 ++++++++++++----
> commit.c | 9 ++++++---
> gpg-interface.c | 13 ++++++++++++-
> gpg-interface.h | 9 ++++++++-
> log-tree.c | 14 ++++++++------
> ref-filter.c | 18 ++++++++++++++----
> tag.c | 15 ++++++++-------
> 9 files changed, 88 insertions(+), 36 deletions(-)
>
> diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
> index 05a92c59d8..29f647e2d9 100644
> --- a/builtin/fmt-merge-msg.c
> +++ b/builtin/fmt-merge-msg.c
> @@ -472,6 +472,7 @@ static void fmt_tag_signature(struct strbuf *tagbuf,
> const char *buf,
> unsigned long len)
> {
> +
> const char *tag_body = strstr(buf, "\n\n");
> if (tag_body) {
> tag_body += 2;Is this hunk a pun to rhyme with the strstr ;-)?
Show 28 quoted lines
> diff --git a/gpg-interface.c b/gpg-interface.c
> index 2d538bcd6e..b25f5c21d8 100644
> --- a/gpg-interface.c
> +++ b/gpg-interface.c
> @@ -345,7 +345,7 @@ void print_signature_buffer(const struct signature_check *sigc, unsigned flags)
> fputs(output, stderr);
> }
>
> -size_t parse_signature(const char *buf, size_t size)
> +size_t parse_signed_buffer(const char *buf, size_t size)
> {
> size_t len = 0;
> size_t match = size;
> @@ -361,6 +361,17 @@ size_t parse_signature(const char *buf, size_t size)
> return match;
> }
>
> +int parse_signature(const char *buf, size_t size, struct strbuf *payload, struct strbuf *signature)
> +{
> + size_t match = parse_signed_buffer(buf, size);
> + if (match != size) {
> + strbuf_add(payload, buf, match);
> + strbuf_add(signature, buf + match, size - match);
> + return 1;
> + }
> + return 0;
> +}
> +