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)
| 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. |
| 133 | func 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. |
searching dependent graphs…