Ejemplo n.º 1
0
func (repo *Repository) CreateBlobFromBuffer(data []byte) (*Oid, error) {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	oid := C.git_oid{}
	ecode := C.git_blob_create_frombuffer(&oid, repo.ptr, unsafe.Pointer(&data[0]), C.size_t(len(data)))
	if ecode < 0 {
		return nil, MakeGitError(ecode)
	}
	return newOidFromC(&oid), nil
}
Ejemplo n.º 2
0
// Create a blob from byte slice.
func (repo *Repository) CreateBlob(buffer []byte) (*Oid, error) {
	oid := new(Oid)
	cbuffer := unsafe.Pointer(&buffer[0])
	defer C.free(cbuffer)
	length := C.size_t(len(buffer))
	ecode := C.git_blob_create_frombuffer(oid.git_oid, repo.git_repository, cbuffer, length)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return oid, nil
}