diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-12-05 14:49:58 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-12-05 14:49:58 +0900 |
| commit | 1b40ddc1a5e2eecd54802c3c6c3c940b0306542a (patch) | |
| tree | ce1c454b13334bc0c46be46b37169a8ccc1ebf91 /commit.c | |
| parent | 85f99338e107a36650257787a350821acc36a81d (diff) | |
| parent | c20f112e5149d1bd0d4741c4b28a65f81318309a (diff) | |
Merge branch 'cc/fast-import-strip-if-invalid'
"git fast-import" learns "--strip-if-invalid" option to drop
invalid cryptographic signature from objects.
* cc/fast-import-strip-if-invalid:
fast-import: add 'strip-if-invalid' mode to --signed-commits=<mode>
commit: refactor verify_commit_buffer()
fast-import: refactor finalize_commit_buffer()
Diffstat (limited to 'commit.c')
| -rw-r--r-- | commit.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -1315,7 +1315,8 @@ free_return: free(buf); } -int check_commit_signature(const struct commit *commit, struct signature_check *sigc) +int verify_commit_buffer(const char *buffer, size_t size, + struct signature_check *sigc) { struct strbuf payload = STRBUF_INIT; struct strbuf signature = STRBUF_INIT; @@ -1323,7 +1324,8 @@ int check_commit_signature(const struct commit *commit, struct signature_check * sigc->result = 'N'; - if (parse_signed_commit(commit, &payload, &signature, the_hash_algo) <= 0) + if (parse_buffer_signed_by_header(buffer, size, &payload, + &signature, the_hash_algo) <= 0) goto out; sigc->payload_type = SIGNATURE_PAYLOAD_COMMIT; @@ -1337,6 +1339,17 @@ int check_commit_signature(const struct commit *commit, struct signature_check * return ret; } +int check_commit_signature(const struct commit *commit, struct signature_check *sigc) +{ + unsigned long size; + const char *buffer = repo_get_commit_buffer(the_repository, commit, &size); + int ret = verify_commit_buffer(buffer, size, sigc); + + repo_unuse_commit_buffer(the_repository, commit, buffer); + + return ret; +} + void verify_merge_signature(struct commit *commit, int verbosity, int check_trust) { |
