Exemple #1
0
func (repo *Repository) ReadNote(ref string, oid *Oid) (*Note, error) {
	note := new(Note)
	cref := C.CString(ref)
	defer C.free(unsafe.Pointer(cref))
	ecode := C.git_note_read(&note.git_note, repo.git_repository, cref, oid.git_oid)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return note, nil
}
Exemple #2
0
// Read reads the note for an object
func (c *NoteCollection) Read(ref string, id *Oid) (*Note, error) {
	var cref *C.char
	if ref == "" {
		cref = nil
	} else {
		cref = C.CString(ref)
		defer C.free(unsafe.Pointer(cref))
	}

	note := new(Note)

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	if ret := C.git_note_read(&note.ptr, c.repo.ptr, cref, id.toC()); ret < 0 {
		return nil, MakeGitError(ret)
	}

	runtime.SetFinalizer(note, (*Note).Free)
	return note, nil
}