From 15434610fec67e704d3ad443b03054d1611f98fe Mon Sep 17 00:00:00 2001 From: lhchavez Date: Sat, 4 Sep 2021 13:49:01 -0700 Subject: Add `CreateCommitWithSignature` (#782) This change adds the wrapper for `git_commit_create_with_signature`. --- commit.go | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) (limited to 'commit.go') diff --git a/commit.go b/commit.go index 3a07fa8..cfc6a63 100644 --- a/commit.go +++ b/commit.go @@ -75,40 +75,11 @@ func (c *Commit) WithSignatureUsing(f CommitSigningCallback) (*Oid, error) { // WithSignature creates a new signed commit from the given signature and signature field func (c *Commit) WithSignature(signature string, signatureField string) (*Oid, error) { - totalCommit := c.ContentToSign() - - oid := new(Oid) - - var csf *C.char = nil - if signatureField != "" { - csf = C.CString(signatureField) - defer C.free(unsafe.Pointer(csf)) - } - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - cTotalCommit := C.CString(totalCommit) - cSignature := C.CString(signature) - defer C.free(unsafe.Pointer(cTotalCommit)) - defer C.free(unsafe.Pointer(cSignature)) - - ret := C.git_commit_create_with_signature( - oid.toC(), - c.Owner().ptr, - cTotalCommit, - cSignature, - csf, + return c.Owner().CreateCommitWithSignature( + c.ContentToSign(), + signature, + signatureField, ) - - runtime.KeepAlive(c) - runtime.KeepAlive(oid) - - if ret < 0 { - return nil, MakeGitError(ret) - } - - return oid, nil } func (c *Commit) ExtractSignature() (string, string, error) { -- cgit v1.2.3