diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to 'source')
| -rw-r--r-- | source/ui-tag.c | 29 |
1 file changed, 25 insertions, 4 deletions
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("<div class='commit-subject'>"); newline = strchr(msg, '\n'); if (newline) @@ -96,6 +111,12 @@ static void print_message(char *msg) html_txt(body); html("</div>"); } + if (signature) { + html("<details class='signature'><summary>Signature</summary><pre>"); + html_txt(signature); + html("</pre></details>"); + free(signature); + } } static void print_annotated_tag(const char *revname, const struct object_id *oid) |
