Esempio n. 1
0
func (v *Repo) Init(path string, isbare uint8) (err error) {
	ecode := C.git_repository_init(&v.git_repo, C.CString(path), C.uint(isbare))
	if ecode < GIT_SUCCESS {
		return LastError()
	}
	return
}
Esempio n. 2
0
File: git.go Progetto: fsouza/gogit
// InitRepository inits a new repository.
//
// If the path does not exist, it will be created.
//
// Returns an instance of Repository, or an error in case of failure.
func InitRepository(path string, bare bool) (*Repository, error) {
	var cbare C.unsigned = 0
	if bare {
		cbare = 1
	}
	repo := new(Repository)
	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))
	if C.git_repository_init(&repo.repository, cpath, cbare) != C.GIT_OK {
		return nil, lastErr()
	}
	return repo, nil
}
Esempio n. 3
0
func InitRepository(path string, bare bool) (*Repository, error) {
	repo := new(Repository)
	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))
	cbare := C.unsigned(c_FALSE)
	if bare {
		cbare = C.unsigned(c_TRUE)
	}
	ecode := C.git_repository_init(&repo.git_repository, cpath, cbare)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return repo, nil
}
Esempio n. 4
0
func InitRepository(path string, isbare bool) (*Repository, error) {
	repo := new(Repository)

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

	ret := C.git_repository_init(&repo.ptr, cpath, ucbool(isbare))
	if ret < 0 {
		return nil, LastError()
	}

	runtime.SetFinalizer(repo, (*Repository).Free)
	return repo, nil
}
Esempio n. 5
0
func GitRepositoryInit(path string, bare UIntBool) (*GitRepository, error) {
	repo := new(GitRepository)

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

	ret := C.git_repository_init(&repo.ptr, cpath, bare.ToInt())
	if ret < 0 {
		return nil, GitErrorLast()
	}

	runtime.SetFinalizer(repo, (*GitRepository).Free)
	return repo, nil
}
Esempio n. 6
0
func InitRepository(path string, isbare bool) (*Repository, error) {
	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	var ptr *C.git_repository
	ret := C.git_repository_init(&ptr, cpath, ucbool(isbare))
	if ret < 0 {
		return nil, MakeGitError(ret)
	}

	return newRepositoryFromC(ptr), nil
}
Esempio n. 7
0
// Initalize a new git repository at the given filesystem path.
// The bare flag controls if the repository should be created as bare or not.
func InitRepository(path string, bare bool) (*Repository, error) {
	p := C.CString(path)
	defer C.free(unsafe.Pointer(p))

	r := new(Repository)

	var bareFlag C.uint
	if bare {
		bareFlag = 1
	}
	if err := gitError(C.git_repository_init(&r.repo, p, bareFlag)); err != nil {
		return nil, err
	}
	return r, nil
}