From 77237f16821ca9403cfc8a7fcdddf129b23a363c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 25 Oct 2026 13:06:39 -1000 Subject: Fold a tag's signature away under its message The armour ran on for more lines than most tag messages, as part of the message itself. git finds the signature for every kind it can sign with, so PGP, SSH and X.509 all fold the same way. --- source/ui-tag.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/ui-tag.c b/source/ui-tag.c index 5fa8a17..246ff12 100644 --- a/source/ui-tag.c +++ b/source/ui-tag.c @@ -11,6 +11,7 @@ #include "cgit.h" #include "filter.h" +#include "gpg-interface.h" #include "html.h" #include "parsing.h" #include "shared.h" @@ -71,17 +72,31 @@ static void print_download_row(const char *revname, const struct object *obj) } /* - * Cutting the subject out terminates the message in place, which is safe only - * because the caller frees it straight after. The blank lines between the - * subject and the body are skipped, as the commit page skips them. + * Cutting the subject and the signature out terminates the message in place, + * which is safe only because the caller frees it straight after. The blank + * lines between the subject and the body are skipped, as the commit page skips + * them. */ static void print_message(char *msg) { - char *newline, *body; + char *newline, *body, *signature = NULL; + size_t len, start; if (!msg) return; + // git finds the signature of any kind it can sign with, PGP, SSH or + // X.509, and it goes in a fold after the message, since its armour + // would otherwise run on for more lines than the message itself. + len = strlen(msg); + start = parse_signed_buffer(msg, len); + if (start < len) { + signature = xstrdup(msg + start); + while (start > 0 && msg[start - 1] == '\n') + start--; + msg[start] = '\0'; + } + html("
"); newline = strchr(msg, '\n'); if (newline) @@ -96,6 +111,12 @@ static void print_message(char *msg) html_txt(body); html("
"); } + if (signature) { + html("
Signature
");
+		html_txt(signature);
+		html("
"); + free(signature); + } } static void print_annotated_tag(const char *revname, const struct object_id *oid) -- cgit 2.9.2