Ejemplo n.º 1
0
Archivo: git.go Proyecto: fsouza/gogit
// SetBool is used to add a boolean setting to the configuration file.
//
// The format of the configuration parameter is the same as in GetBool. If the
// configuration parameter is not declared in the config file, it will be
// created. Example of use:
//
//     err := config.SetBool("core.ignorecase", true)
//     if err != nil {
//         panic(err)
//     }
func (c *Config) SetBool(name string, value bool) error {
	var v C.int = 0
	if value {
		v = 1
	}
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	if C.git_config_set_bool(c.config, cname, v) != C.GIT_OK {
		return lastErr()
	}
	return nil
}
Ejemplo n.º 2
0
func (cfg *Config) SetBool(name string, value bool) error {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	cvalue := C.int(c_FALSE)
	if value {
		cvalue = C.int(c_TRUE)
	}
	ecode := C.git_config_set_bool(cfg.git_config, cname, cvalue)
	if ecode != git_SUCCESS {
		return gitError()
	}
	return nil
}
Ejemplo n.º 3
0
Archivo: config.go Proyecto: wid/git2go
func (c *Config) SetBool(name string, value bool) (err error) {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_config_set_bool(c.ptr, cname, cbool(value))
	if ret < 0 {
		return MakeGitError(ret)
	}

	return nil
}