diff options
author | Tyler Ang-Wanek <tylerw@axosoft.com> | 2019-07-02 09:53:49 -0700 |
---|---|---|
committer | Tyler Ang-Wanek <tylerw@axosoft.com> | 2019-07-02 09:56:19 -0700 |
commit | 759471056f1d9fe36dde447e0ce08ba3ce13a7be (patch) | |
tree | e76a40b5dadcb7f7e8935839a8f76f268f4dbe8e /src/commit.c | |
parent | 3b8a6f43974e23a554d852e09fb3a0d94accf6dc (diff) | |
download | libgit2-759471056f1d9fe36dde447e0ce08ba3ce13a7be.tar.gz |
commit: git_commit_create_with_signature should support null signature
If provided with a null signature, skip adding the signature header and create the commit anyway.
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/commit.c b/src/commit.c index 513fdccaf..49550d35e 100644 --- a/src/commit.c +++ b/src/commit.c @@ -80,8 +80,8 @@ on_error: } static int validate_tree_and_parents(git_array_oid_t *parents, git_repository *repo, const git_oid *tree, - git_commit_parent_callback parent_cb, void *parent_payload, - const git_oid *current_id, bool validate) + git_commit_parent_callback parent_cb, void *parent_payload, + const git_oid *current_id, bool validate) { size_t i; int error; @@ -152,8 +152,8 @@ static int git_commit__create_internal( goto cleanup; error = git_commit__create_buffer_internal(&buf, author, committer, - message_encoding, message, tree, - &parents); + message_encoding, message, tree, + &parents); if (error < 0) goto cleanup; @@ -582,7 +582,7 @@ const char *git_commit_body(git_commit *commit) break; if (*msg) - commit->body = git__strndup(msg, end - msg + 1); + commit->body = git__strndup(msg, end - msg + 1); } return commit->body; @@ -876,12 +876,15 @@ int git_commit_create_with_signature( return -1; } - field = signature_field ? signature_field : "gpgsig"; - /* The header ends after the first LF */ header_end++; git_buf_put(&commit, commit_content, header_end - commit_content); - format_header_field(&commit, field, signature); + + if (signature != NULL) { + field = signature_field ? signature_field : "gpgsig"; + format_header_field(&commit, field, signature); + } + git_buf_puts(&commit, header_end); if (git_buf_oom(&commit)) |