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

Function NewMempack

mempack.go:26–48  ·  view source on GitHub ↗

NewMempack creates a new mempack instance and registers it to the ODB.

(odb *Odb)

Source from the content-addressed store, hash-verified

24
25// NewMempack creates a new mempack instance and registers it to the ODB.
26func NewMempack(odb *Odb) (mempack *Mempack, err error) {
27 mempack = new(Mempack)
28
29 runtime.LockOSThread()
30 defer runtime.UnlockOSThread()
31
32 ret := C.git_mempack_new(&mempack.ptr)
33 if ret < 0 {
34 return nil, MakeGitError(ret)
35 }
36
37 ret = C.git_odb_add_backend(odb.ptr, mempack.ptr, C.int(999))
38 runtime.KeepAlive(odb)
39 if ret < 0 {
40 // Since git_odb_add_alternate() takes ownership of the ODB backend, the
41 // only case in which we free the mempack's memory is if it fails to be
42 // added to the ODB.
43 C._go_git_odb_backend_free(mempack.ptr)
44 return nil, MakeGitError(ret)
45 }
46
47 return mempack, nil
48}
49
50// Dump dumps all the queued in-memory writes to a packfile.
51//

Callers 1

TestMempackFunction · 0.85

Calls 1

MakeGitErrorFunction · 0.85

Tested by 1

TestMempackFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…