summaryrefslogtreecommitdiff
path: root/pretty.c
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2013-02-14 16:04:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-02-14 17:30:22 (GMT)
commit4a868fd655a72c2663d9519363162db467baccb2 (patch)
treeaf5a50b40cec2b769dcb88f3c19450e85fbe9552 /pretty.c
parent9cc4ac8ff1ae84f9435f2c7de3f7ab796103adba (diff)
downloadgit-4a868fd655a72c2663d9519363162db467baccb2.zip
git-4a868fd655a72c2663d9519363162db467baccb2.tar.gz
git-4a868fd655a72c2663d9519363162db467baccb2.tar.bz2
pretty: parse the gpg status lines rather than the output
Currently, parse_signature_lines() parses the gpg output for strings which depend on LANG so it fails to recognize good commit signatures (and thus does not fill in %G? and the like) in most locales. Make it parse the status lines from gpg instead, which are the proper machine interface. This fixes the problem described above. There is a change in behavior for "%GS" which we intentionally do not work around: "%GS" used to put quotes around the signer's uid (or rather: it inherited from the gpg user output). We output the uid without quotes now, just like author and committer names. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pretty.c')
-rw-r--r--pretty.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/pretty.c b/pretty.c
index 1ca86dc..9ffe7bc 100644
--- a/pretty.c
+++ b/pretty.c
@@ -692,6 +692,7 @@ struct format_commit_context {
unsigned commit_signature_parsed:1;
struct {
char *gpg_output;
+ char *gpg_status;
char good_bad;
char *signer;
} signature;
@@ -881,13 +882,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++) {
@@ -896,7 +897,7 @@ 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);
+ found += strlen(signature_check[i].check)+17;
next = strchrnul(found, '\n');
ctx->signature.signer = xmemdupz(found, next - found);
break;
@@ -908,6 +909,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;
@@ -917,13 +919,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, NULL);
+ &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);