Add function to open repository from subpaths

This commit is contained in:
cloudson 2014-04-26 20:35:22 -03:00 committed by Carlos Martín Nieto
parent 80ad996dc1
commit 591a67fef8
1 changed files with 18 additions and 0 deletions

View File

@ -24,6 +24,24 @@ func OpenRepository(path string) (*Repository, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_repository_open(&repo.ptr, cpath)
if ret < 0 {
return nil, MakeGitError(ret)
}
runtime.SetFinalizer(repo, (*Repository).Free)
return repo, nil
}
func OpenRepositoryExtended(path string) (*Repository, error) {
repo := new(Repository)
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
runtime.LockOSThread()
defer runtime.UnlockOSThread()
ret := C.git_repository_open_ext(&repo.ptr, cpath, 0, nil)
if ret < 0 {
return nil, MakeGitError(ret)