示例#1
0
文件: git.go 项目: stettberger/go-git
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
}
示例#2
0
文件: git.go 项目: 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
}
示例#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
}
示例#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
}
示例#5
0
文件: git.go 项目: jbrimeyer/Summa
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
}
示例#6
0
文件: repository.go 项目: wid/git2go
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
}
示例#7
0
文件: repository.go 项目: tmc/goit
// 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
}