summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-04-03 09:26:27 -0700
committerJunio C Hamano <gitster@pobox.com>2013-04-03 09:26:27 -0700
commitb771d8d7cf9dd9d5901e68526be471722870a9f8 (patch)
treee1035ced0b988881dfede8fc5556575e78ab090f /pretty.c
parent14c79b1faa113707d8955912af6064d9844f71eb (diff)
parent0174eeaa736226a0bea19e9bf88c270d61aa9cce (diff)
downloadgit-b771d8d7cf9dd9d5901e68526be471722870a9f8.tar.gz
Merge branch 'mg/gpg-interface-using-status' into maint
Verification of signed tags were not done correctly when not in C or en/US locale. * mg/gpg-interface-using-status: pretty: make %GK output the signing key for signed commits pretty: parse the gpg status lines rather than the output gpg_interface: allow to request status return log-tree: rely upon the check in the gpg_interface gpg-interface: check good signature in a reliable way
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/pretty.c b/pretty.c
index 41ffbc9240..41f04e669d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -769,8 +769,10 @@ struct format_commit_context {
unsigned commit_signature_parsed:1;
struct {
char *gpg_output;
+ char *gpg_status;
char good_bad;
char *signer;
+ char *key;
} signature;
char *message;
size_t width, indent1, indent2;
@@ -958,13 +960,13 @@ static struct {
char result;
const char *check;
} signature_check[] = {
- { 'G', ": Good signature from " },
- { 'B', ": BAD signature from " },
+ { 'G', "\n[GNUPG:] GOODSIG " },
+ { 'B', "\n[GNUPG:] BADSIG " },
};
static void parse_signature_lines(struct format_commit_context *ctx)
{
- const char *buf = ctx->signature.gpg_output;
+ const char *buf = ctx->signature.gpg_status;
int i;
for (i = 0; i < ARRAY_SIZE(signature_check); i++) {
@@ -974,6 +976,8 @@ static void parse_signature_lines(struct format_commit_context *ctx)
continue;
ctx->signature.good_bad = signature_check[i].result;
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;
@@ -985,6 +989,7 @@ static void parse_commit_signature(struct format_commit_context *ctx)
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;
struct strbuf gpg_output = STRBUF_INIT;
+ struct strbuf gpg_status = STRBUF_INIT;
int status;
ctx->commit_signature_parsed = 1;
@@ -994,13 +999,15 @@ static void parse_commit_signature(struct format_commit_context *ctx)
goto out;
status = verify_signed_buffer(payload.buf, payload.len,
signature.buf, signature.len,
- &gpg_output);
+ &gpg_output, &gpg_status);
if (status && !gpg_output.len)
goto out;
ctx->signature.gpg_output = strbuf_detach(&gpg_output, NULL);
+ ctx->signature.gpg_status = strbuf_detach(&gpg_status, NULL);
parse_signature_lines(ctx);
out:
+ strbuf_release(&gpg_status);
strbuf_release(&gpg_output);
strbuf_release(&payload);
strbuf_release(&signature);
@@ -1210,6 +1217,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;
}