gpg-interface: provide access to the payload
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>
Michael J Gruber committed
Jun 23, 2014 at 09:05 UTC
71c214c840782a67801fc8dbf5fe8a4f4fc62d01
3 files changed
+4
commit.c
+1
@@ -1219,6 +1219,7 @@ void check_commit_signature(const struct commit* commit, struct signature_check
1219
&gpg_output, &gpg_status);
1220
if (status && !gpg_output.len)
1221
goto out;
1222
+ sigc->payload = strbuf_detach(&payload, NULL);
1223
sigc->gpg_output = strbuf_detach(&gpg_output, NULL);
1224
sigc->gpg_status = strbuf_detach(&gpg_status, NULL);
1225
parse_gpg_output(sigc);
gpg-interface.c
+2
@@ -9,10 +9,12 @@ static const char *gpg_program = "gpg";
9
10
void signature_check_clear(struct signature_check *sigc)
11
{
12
+ free(sigc->payload);
13
free(sigc->gpg_output);
14
free(sigc->gpg_status);
15
free(sigc->signer);
16
free(sigc->key);
17
+ sigc->payload = NULL;
18
sigc->gpg_output = NULL;
19
sigc->gpg_status = NULL;
20
sigc->signer = NULL;
gpg-interface.h
+1
@@ -2,6 +2,7 @@
2
#define GPG_INTERFACE_H
3
4
struct signature_check {
5
+ char *payload;
6
char *gpg_output;
7
char *gpg_status;
8
char result; /* 0 (not checked),