MCPcopy Create free account
hub / github.com/libgit2/git2go / Create

Method Create

note.go:21–62  ·  view source on GitHub ↗

Create adds a note for an object

(
	ref string, author, committer *Signature, id *Oid,
	note string, force bool)

Source from the content-addressed store, hash-verified

19
20// Create adds a note for an object
21func (c *NoteCollection) Create(
22 ref string, author, committer *Signature, id *Oid,
23 note string, force bool) (*Oid, error) {
24
25 oid := new(Oid)
26
27 var cref *C.char
28 if ref == "" {
29 cref = nil
30 } else {
31 cref = C.CString(ref)
32 defer C.free(unsafe.Pointer(cref))
33 }
34
35 authorSig, err := author.toC()
36 if err != nil {
37 return nil, err
38 }
39 defer C.git_signature_free(authorSig)
40
41 committerSig, err := committer.toC()
42 if err != nil {
43 return nil, err
44 }
45 defer C.git_signature_free(committerSig)
46
47 cnote := C.CString(note)
48 defer C.free(unsafe.Pointer(cnote))
49
50 runtime.LockOSThread()
51 defer runtime.UnlockOSThread()
52
53 ret := C.git_note_create(
54 oid.toC(), c.repo.ptr, cref, authorSig,
55 committerSig, id.toC(), cnote, cbool(force))
56 runtime.KeepAlive(c)
57 runtime.KeepAlive(id)
58 if ret < 0 {
59 return nil, MakeGitError(ret)
60 }
61 return oid, nil
62}
63
64// Read reads the note for an object
65func (c *NoteCollection) Read(ref string, id *Oid) (*Note, error) {

Callers

nothing calls this directly

Calls 4

cboolFunction · 0.85
MakeGitErrorFunction · 0.85
freeMethod · 0.80
toCMethod · 0.45

Tested by

no test coverage detected