Merge branch 'bc/gpg-verify-raw'
"git verify-tag" and "git verify-commit" have been taught to share more code, and then learned to optionally show the verification message from the underlying GPG implementation. * bc/gpg-verify-raw: verify-tag: add option to print raw gpg status information verify-commit: add option to print raw gpg status information gpg: centralize printing signature buffers gpg: centralize signature check verify-commit: add test for exit status on untrusted signature verify-tag: share code with verify-commit verify-tag: add tests
This commit is contained in:
21
commit.c
21
commit.c
@ -1232,33 +1232,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;
|
||||
struct strbuf gpg_output = STRBUF_INIT;
|
||||
struct strbuf gpg_status = STRBUF_INIT;
|
||||
int status;
|
||||
int ret = 1;
|
||||
|
||||
sigc->result = 'N';
|
||||
|
||||
if (parse_signed_commit(commit, &payload, &signature) <= 0)
|
||||
goto out;
|
||||
status = verify_signed_buffer(payload.buf, payload.len,
|
||||
signature.buf, signature.len,
|
||||
&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);
|
||||
ret = check_signature(payload.buf, payload.len, signature.buf,
|
||||
signature.len, sigc);
|
||||
|
||||
out:
|
||||
strbuf_release(&gpg_status);
|
||||
strbuf_release(&gpg_output);
|
||||
strbuf_release(&payload);
|
||||
strbuf_release(&signature);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user