示例#1
0
文件: git.go 项目: fsouza/gogit
// GetBool is used to get boolean config values.
//
// The dot notation is used for configuration parameters. Example:
//
//     v, err := config.GetBool("core.ignorecase")
//     // check errors and use v
func (c *Config) GetBool(name string) (bool, error) {
	var v C.int
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	if C.git_config_get_bool(&v, c.config, cname) != C.GIT_OK {
		return false, lastErr()
	}
	return v == 1, nil
}
示例#2
0
文件: config.go 项目: jgrocho/go-git2
func (cfg *Config) GetBool(name string) (bool, error) {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	var cval C.int
	ecode := C.git_config_get_bool(&cval, cfg.git_config, cname)
	if ecode != git_SUCCESS {
		return false, gitError()
	}
	return (cval != c_FALSE), nil
}
示例#3
0
文件: config.go 项目: wid/git2go
func (c *Config) LookupBool(name string) (bool, error) {
	var out C.int
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_config_get_bool(&out, c.ptr, cname)
	if ret < 0 {
		return false, MakeGitError(ret)
	}

	return out != 0, nil
}