summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2015-06-21 23:14:40 +0000
committerJunio C Hamano <gitster@pobox.com>2015-06-22 14:20:46 -0700
commit434060ec6d9bf50f095db901da3fb9b557e11df1 (patch)
tree7a7dc99fb6b8e1e5eaa566ec4eb5e29ff807e8f2 /commit.c
parent8e98e5f27aba812c0f095b7e546871e14a4139f6 (diff)
downloadgit-434060ec6d9bf50f095db901da3fb9b557e11df1.tar.gz
gpg: centralize signature check
verify-commit and verify-tag both share a central codepath for verifying commits: check_signature. However, verify-tag exited successfully for untrusted signature, while verify-commit exited unsuccessfully. Centralize this signature check and make verify-commit adopt the older verify-tag behavior. This behavior is more logical anyway, as the signature is in fact valid, whether or not there's a path of trust to the author. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/commit.c b/commit.c
index d07a984985..909419a13b 100644
--- a/commit.c
+++ b/commit.c
@@ -1227,20 +1227,24 @@ free_return:
free(buf);
}
-void check_commit_signature(const struct commit *commit, struct signature_check *sigc)
+int check_commit_signature(const struct commit *commit, struct signature_check *sigc)
{
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;
+ int ret = 1;
sigc->result = 'N';
if (parse_signed_commit(commit, &payload, &signature) <= 0)
goto out;
- check_signature(payload.buf, payload.len, signature.buf, signature.len, sigc);
+ ret = check_signature(payload.buf, payload.len, signature.buf,
+ signature.len, sigc);
out:
strbuf_release(&payload);
strbuf_release(&signature);
+
+ return ret;
}