Browse Source

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>
maint
Michael J Gruber 12 years ago committed by Junio C Hamano
parent
commit
0174eeaa73
  1. 1
      Documentation/pretty-formats.txt
  2. 9
      pretty.c

1
Documentation/pretty-formats.txt

@ -133,6 +133,7 @@ The placeholders are:
- '%GG': raw verification message from GPG for a signed commit - '%GG': raw verification message from GPG for a signed commit
- '%G?': show either "G" for Good or "B" for Bad 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 - '%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': reflog selector, e.g., `refs/stash@{1}`
- '%gd': shortened reflog selector, e.g., `stash@{1}` - '%gd': shortened reflog selector, e.g., `stash@{1}`
- '%gn': reflog identity name - '%gn': reflog identity name

9
pretty.c

@ -695,6 +695,7 @@ struct format_commit_context {
char *gpg_status; char *gpg_status;
char good_bad; char good_bad;
char *signer; char *signer;
char *key;
} signature; } signature;
char *message; char *message;
size_t width, indent1, indent2; size_t width, indent1, indent2;
@ -897,7 +898,9 @@ static void parse_signature_lines(struct format_commit_context *ctx)
if (!found) if (!found)
continue; continue;
ctx->signature.good_bad = signature_check[i].result; 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'); next = strchrnul(found, '\n');
ctx->signature.signer = xmemdupz(found, next - found); ctx->signature.signer = xmemdupz(found, next - found);
break; break;
@ -1130,6 +1133,10 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
if (c->signature.signer) if (c->signature.signer)
strbuf_addstr(sb, c->signature.signer); strbuf_addstr(sb, c->signature.signer);
break; break;
case 'K':
if (c->signature.key)
strbuf_addstr(sb, c->signature.key);
break;
} }
return 2; return 2;
} }

Loading…
Cancel
Save