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

Method Read

odb.go:395–415  ·  view source on GitHub ↗

Read reads from the stream

(data []byte)

Source from the content-addressed store, hash-verified

393
394// Read reads from the stream
395func (stream *OdbReadStream) Read(data []byte) (int, error) {
396 header := (*reflect.SliceHeader)(unsafe.Pointer(&data))
397 ptr := (*C.char)(unsafe.Pointer(header.Data))
398 size := C.size_t(header.Cap)
399
400 runtime.LockOSThread()
401 defer runtime.UnlockOSThread()
402
403 ret := C.git_odb_stream_read(stream.ptr, ptr, size)
404 runtime.KeepAlive(stream)
405 if ret < 0 {
406 return 0, MakeGitError(ret)
407 }
408 if ret == 0 {
409 return 0, io.EOF
410 }
411
412 header.Len = int(ret)
413
414 return len(data), nil
415}
416
417// Close is a dummy function in order to implement the Closer and
418// ReadCloser interfaces

Callers

nothing calls this directly

Calls 1

MakeGitErrorFunction · 0.85

Tested by

no test coverage detected