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

Method Write

odb.go:435–450  ·  view source on GitHub ↗

Write writes to the stream

(data []byte)

Source from the content-addressed store, hash-verified

433
434// Write writes to the stream
435func (stream *OdbWriteStream) Write(data []byte) (int, error) {
436 header := (*reflect.SliceHeader)(unsafe.Pointer(&data))
437 ptr := (*C.char)(unsafe.Pointer(header.Data))
438 size := C.size_t(header.Len)
439
440 runtime.LockOSThread()
441 defer runtime.UnlockOSThread()
442
443 ret := C.git_odb_stream_write(stream.ptr, ptr, size)
444 runtime.KeepAlive(stream)
445 if ret < 0 {
446 return 0, MakeGitError(ret)
447 }
448
449 return len(data), nil
450}
451
452// Close signals that all the data has been written and stores the
453// resulting object id in the stream's Id field.

Callers

nothing calls this directly

Calls 1

MakeGitErrorFunction · 0.85

Tested by

no test coverage detected