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

Method Write

odb.go:139–160  ·  view source on GitHub ↗
(data []byte, otype ObjectType)

Source from the content-addressed store, hash-verified

137}
138
139func (v *Odb) Write(data []byte, otype ObjectType) (oid *Oid, err error) {
140 oid = new(Oid)
141
142 runtime.LockOSThread()
143 defer runtime.UnlockOSThread()
144
145 var size C.size_t
146 if len(data) > 0 {
147 size = C.size_t(len(data))
148 } else {
149 data = []byte{0}
150 size = C.size_t(0)
151 }
152
153 ret := C.git_odb_write(oid.toC(), v.ptr, unsafe.Pointer(&data[0]), size, C.git_object_t(otype))
154 runtime.KeepAlive(v)
155 if ret < 0 {
156 return nil, MakeGitError(ret)
157 }
158
159 return oid, nil
160}
161
162func (v *Odb) Read(oid *Oid) (obj *OdbObject, err error) {
163 obj = new(OdbObject)

Callers 15

TestMempackFunction · 0.95
TestCreateCommitBufferFunction · 0.45
TestCreateCommitFromIdsFunction · 0.45
prepareStashRepoFunction · 0.45
seedTestRepoOptFunction · 0.45
updateReadmeFunction · 0.45
TestDiffBlobsFunction · 0.45
TestIndexWriteTreeToFunction · 0.45
TestIndexRemoveDirectoryFunction · 0.45
TestIndexOpenFunction · 0.45

Calls 2

MakeGitErrorFunction · 0.85
toCMethod · 0.45

Tested by 15

TestMempackFunction · 0.76
TestCreateCommitBufferFunction · 0.36
TestCreateCommitFromIdsFunction · 0.36
prepareStashRepoFunction · 0.36
seedTestRepoOptFunction · 0.36
updateReadmeFunction · 0.36
TestDiffBlobsFunction · 0.36
TestIndexWriteTreeToFunction · 0.36
TestIndexRemoveDirectoryFunction · 0.36
TestIndexOpenFunction · 0.36
TestTreeBuilderInsertFunction · 0.36