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

Function OpenIndex

index.go:133–147  ·  view source on GitHub ↗

OpenIndex creates a new index at the given path. If the file does not exist it will be created when Write() is called.

(path string)

Source from the content-addressed store, hash-verified

131// OpenIndex creates a new index at the given path. If the file does
132// not exist it will be created when Write() is called.
133func OpenIndex(path string) (*Index, error) {
134 var ptr *C.git_index
135
136 var cpath = C.CString(path)
137 defer C.free(unsafe.Pointer(cpath))
138
139 runtime.LockOSThread()
140 defer runtime.UnlockOSThread()
141
142 if err := C.git_index_open(&ptr, cpath); err < 0 {
143 return nil, MakeGitError(err)
144 }
145
146 return newIndexFromC(ptr, nil), nil
147}
148
149// Path returns the index' path on disk or an empty string if it
150// exists only in memory.

Callers 1

TestIndexOpenFunction · 0.85

Calls 3

MakeGitErrorFunction · 0.85
newIndexFromCFunction · 0.85
freeMethod · 0.80

Tested by 1

TestIndexOpenFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…