Esempio n. 1
0
func OpenIndex(path string) (*Index, error) {
	idx := new(Index)
	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))
	ecode := C.git_index_open(&idx.git_index, cpath)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return idx, nil
}
Esempio n. 2
0
File: index.go Progetto: wid/git2go
// OpenIndex creates a new index at the given path. If the file does
// not exist it will be created when Write() is called.
func OpenIndex(path string) (*Index, error) {
	var ptr *C.git_index

	var cpath = C.CString(path)
	defer C.free(unsafe.Pointer(cpath))

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	if err := C.git_index_open(&ptr, cpath); err < 0 {
		return nil, MakeGitError(err)
	}

	return newIndexFromC(ptr), nil
}