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

Method Write

indexer.go:56–71  ·  view source on GitHub ↗

Write adds data to the indexer.

(data []byte)

Source from the content-addressed store, hash-verified

54
55// Write adds data to the indexer.
56func (indexer *Indexer) Write(data []byte) (int, error) {
57 header := (*reflect.SliceHeader)(unsafe.Pointer(&data))
58 ptr := unsafe.Pointer(header.Data)
59 size := C.size_t(header.Len)
60
61 runtime.LockOSThread()
62 defer runtime.UnlockOSThread()
63
64 ret := C.git_indexer_append(indexer.ptr, ptr, size, &indexer.stats)
65 runtime.KeepAlive(indexer)
66 if ret < 0 {
67 return 0, MakeGitError(ret)
68 }
69
70 return len(data), nil
71}
72
73// Commit finalizes the pack and index. It resolves any pending deltas and
74// writes out the index file.

Callers 1

TestIndexerOutOfOrderFunction · 0.95

Calls 1

MakeGitErrorFunction · 0.85

Tested by 1

TestIndexerOutOfOrderFunction · 0.76