Esempio n. 1
0
File: config.go Progetto: wid/git2go
// OpenLevel creates a single-level focused config object from a multi-level one
func (c *Config) OpenLevel(parent *Config, level ConfigLevel) (*Config, error) {
	config := new(Config)

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_config_open_level(&config.ptr, parent.ptr, C.git_config_level_t(level))
	if ret < 0 {
		return nil, MakeGitError(ret)
	}

	return config, nil
}
Esempio n. 2
0
File: config.go Progetto: wid/git2go
// AddFile adds a file-backed backend to the config object at the specified level.
func (c *Config) AddFile(path string, level ConfigLevel, force bool) error {
	cpath := C.CString(path)
	defer C.free(unsafe.Pointer(cpath))

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_config_add_file_ondisk(c.ptr, cpath, C.git_config_level_t(level), cbool(force))
	if ret < 0 {
		return MakeGitError(ret)
	}

	return nil
}