pretty: make %GK output the signing key for signed commits

In order to employ signed keys in an automated way it is absolutely necessary to check which keys the signatures come from. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Feb 14, 2013 at 17:04 UTC 0174eeaa736226a0bea19e9bf88c270d61aa9cce
2 files changed +9 -1
Documentation/pretty-formats.txt
+1
@@ -133,6 +133,7 @@ The placeholders are:
133 - '%GG': raw verification message from GPG for a signed commit
134 - '%G?': show either "G" for Good or "B" for Bad for a signed commit
135 - '%GS': show the name of the signer for a signed commit
136 +- '%GK': show the key used to sign a signed commit
137 - '%gD': reflog selector, e.g., `refs/stash@{1}`
138 - '%gd': shortened reflog selector, e.g., `stash@{1}`
139 - '%gn': reflog identity name
pretty.c
+8 -1
@@ -695,6 +695,7 @@ struct format_commit_context {
695 char *gpg_status;
696 char good_bad;
697 char *signer;
698 + char *key;
699 } signature;
700 char *message;
701 size_t width, indent1, indent2;
@@ -897,7 +898,9 @@ static void parse_signature_lines(struct format_commit_context *ctx)
898 if (!found)
899 continue;
900 ctx->signature.good_bad = signature_check[i].result;
900 - found += strlen(signature_check[i].check)+17;
901 + found += strlen(signature_check[i].check);
902 + ctx->signature.key = xmemdupz(found, 16);
903 + found += 17;
904 next = strchrnul(found, '\n');
905 ctx->signature.signer = xmemdupz(found, next - found);
906 break;
@@ -1130,6 +1133,10 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
1133 if (c->signature.signer)
1134 strbuf_addstr(sb, c->signature.signer);
1135 break;
1136 + case 'K':
1137 + if (c->signature.key)
1138 + strbuf_addstr(sb, c->signature.key);
1139 + break;
1140 }
1141 return 2;
1142 }