git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/5] pretty: make %GK output the signing key for signed commits

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Feb 14, 2013, 16:04 UTC
Message-ID
<6787e82ff88f641eeb17245e93e9240e61270842.1360857415.git.git@drmicha.warpmail.net>
In-Reply-To
<CAJ9Ak2pLqUesOWKNtjwG7P_BW7-EqJP4Kaj0FF_+72Wn=oGoew@mail.gmail.com>
Because we can.

No, really: In order to employ signed keys in an automated way it is absolutely necessary to check which keys the signatures come from. Now you can.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 Documentation/pretty-formats.txt | 1 +
 pretty.c                         | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 105f18a..2939655 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -133,6 +133,7 @@ The placeholders are:
 - '%GG': raw verification message from GPG for a signed commit
 - '%G?': show either "G" for Good or "B" for Bad for a signed commit
 - '%GS': show the name of the signer for a signed commit
+- '%GK': show the key used to sign a signed commit
 - '%gD': reflog selector, e.g., `refs/stash@{1}`
 - '%gd': shortened reflog selector, e.g., `stash@{1}`
 - '%gn': reflog identity name
diff --git a/pretty.c b/pretty.c
index 973b912..b57adef 100644
--- a/pretty.c
+++ b/pretty.c
@@ -762,6 +762,7 @@ struct format_commit_context {
 		char *gpg_status;
 		char good_bad;
 		char *signer;
+		char *key;
 	} signature;
 	char *message;
 	size_t width, indent1, indent2;
@@ -964,7 +965,9 @@ static void parse_signature_lines(struct format_commit_context *ctx)
 		if (!found)
 			continue;
 		ctx->signature.good_bad = signature_check[i].result;
-		found += strlen(signature_check[i].check)+17;
+		found += strlen(signature_check[i].check);
+		ctx->signature.key = xmemdupz(found, 16);
+		found += 17;
 		next = strchrnul(found, '\n');
 		ctx->signature.signer = xmemdupz(found, next - found);
 		break;
@@ -1204,6 +1207,10 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
 			if (c->signature.signer)
 				strbuf_addstr(sb, c->signature.signer);
 			break;
+		case 'K':
+			if (c->signature.key)
+				strbuf_addstr(sb, c->signature.key);
+			break;
 		}
 		return 2;
 	}
-- 
1.8.1.3.797.ge0260c7
Previous: Michael J GruberNext: Junio C Hamano
Message 11 of 14 in “[BUG] Veryfing signatures in git log fails when language is not english”
  1. XANiFeb 14, 2013
  2. Michael J GruberFeb 14, 2013
  3. Mariusz GronczewskiFeb 14, 2013
  4. 0/5 gpg_interface: use the statusMichael J Gruber, Feb 14, 2013
  5. 1/5 gpg-interface: check good signature in a reliable wayMichael J Gruber, Feb 14, 2013
  6. Junio C HamanoFeb 14, 2013
  7. Michael J GruberFeb 15, 2013
  8. 2/5 log-tree: rely upon the check in the gpg_interfaceMichael J Gruber, Feb 14, 2013
  9. 3/5 gpg_interface: allow to request status returnMichael J Gruber, Feb 14, 2013
  10. 4/5 pretty: parse the gpg status lines rather than the outputMichael J Gruber, Feb 14, 2013
  11. 5/5 pretty: make %GK output the signing key for signed commitsMichael J Gruber, Feb 14, 2013
  12. Junio C HamanoFeb 14, 2013
  13. Mariusz GronczewskiFeb 15, 2013
  14. Junio C HamanoFeb 15, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.