gpg-interface: provide access to the payload
authorMichael J Gruber <git@drmicha.warpmail.net>
Mon, 23 Jun 2014 07:05:48 +0000 (09:05 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Jun 2014 22:50:30 +0000 (15:50 -0700)
In contrast to tag signatures, commit signatures are put into the
header, that is between the other header parts and commit messages.

Provide access to the commit content sans the signature, which is the
payload that is actually signed. Commit signature verification does the
parsing anyways, and callers may wish to act on or display the commit
object sans the signature.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c
gpg-interface.c
gpg-interface.h
index f4793316a21fe5f3ee1932f7e24cf4ab0920b04c..e9686b2df438bf9680e7ebcdd84c406b88e53ea6 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -1219,6 +1219,7 @@ void check_commit_signature(const struct commit* commit, struct signature_check
                                      &gpg_output, &gpg_status);
        if (status && !gpg_output.len)
                goto out;
+       sigc->payload = strbuf_detach(&payload, NULL);
        sigc->gpg_output = strbuf_detach(&gpg_output, NULL);
        sigc->gpg_status = strbuf_detach(&gpg_status, NULL);
        parse_gpg_output(sigc);
index e71b59daf67b28f0699035e7834bb6c0b56c5425..ff07012726ea28daa2551966d0555d2e8efa2375 100644 (file)
@@ -9,10 +9,12 @@ static const char *gpg_program = "gpg";
 
 void signature_check_clear(struct signature_check *sigc)
 {
+       free(sigc->payload);
        free(sigc->gpg_output);
        free(sigc->gpg_status);
        free(sigc->signer);
        free(sigc->key);
+       sigc->payload = NULL;
        sigc->gpg_output = NULL;
        sigc->gpg_status = NULL;
        sigc->signer = NULL;
index 9f0784a411da27a2d0a7ea92f6bc4e0eb8f1f974..37c23daff010b0de18fa12ff6a6167f45ff41ffc 100644 (file)
@@ -2,6 +2,7 @@
 #define GPG_INTERFACE_H
 
 struct signature_check {
+       char *payload;
        char *gpg_output;
        char *gpg_status;
        char result; /* 0 (not checked),