Add Go functions for git_config_find_* functions
ConfigFindGlobal -> git_config_find_global ConfigFindSystem -> git_config_find_system ConfigFindXDG -> git_config_find_xdg
This commit is contained in:
parent
57412d0293
commit
548bb9b5e9
52
config.go
52
config.go
|
@ -35,14 +35,14 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigEntry struct {
|
type ConfigEntry struct {
|
||||||
Name string
|
Name string
|
||||||
Value string
|
Value string
|
||||||
Level ConfigLevel
|
Level ConfigLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConfigEntryFromC(centry *C.git_config_entry) *ConfigEntry {
|
func newConfigEntryFromC(centry *C.git_config_entry) *ConfigEntry {
|
||||||
return &ConfigEntry{
|
return &ConfigEntry{
|
||||||
Name: C.GoString(centry.name),
|
Name: C.GoString(centry.name),
|
||||||
Value: C.GoString(centry.value),
|
Value: C.GoString(centry.value),
|
||||||
Level: ConfigLevel(centry.level),
|
Level: ConfigLevel(centry.level),
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,6 @@ func (c *Config) AddFile(path string, level ConfigLevel, force bool) error {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
|
||||||
ret := C.git_config_add_file_ondisk(c.ptr, cpath, C.git_config_level_t(level), cbool(force))
|
ret := C.git_config_add_file_ondisk(c.ptr, cpath, C.git_config_level_t(level), cbool(force))
|
||||||
if ret < 0 {
|
if ret < 0 {
|
||||||
return MakeGitError(ret)
|
return MakeGitError(ret)
|
||||||
|
@ -130,7 +129,6 @@ func (c *Config) LookupString(name string) (string, error) {
|
||||||
return C.GoString(ptr), nil
|
return C.GoString(ptr), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *Config) LookupBool(name string) (bool, error) {
|
func (c *Config) LookupBool(name string) (bool, error) {
|
||||||
var out C.int
|
var out C.int
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
|
@ -234,7 +232,6 @@ func (c *Config) SetInt32(name string, value int32) (err error) {
|
||||||
cname := C.CString(name)
|
cname := C.CString(name)
|
||||||
defer C.free(unsafe.Pointer(cname))
|
defer C.free(unsafe.Pointer(cname))
|
||||||
|
|
||||||
|
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
@ -368,3 +365,48 @@ func (iter *ConfigIterator) Free() {
|
||||||
runtime.SetFinalizer(iter, nil)
|
runtime.SetFinalizer(iter, nil)
|
||||||
C.free(unsafe.Pointer(iter.ptr))
|
C.free(unsafe.Pointer(iter.ptr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ConfigFindGlobal() (string, error) {
|
||||||
|
var buf C.git_buf
|
||||||
|
defer C.git_buf_free(&buf)
|
||||||
|
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
ret := C.git_config_find_global(&buf)
|
||||||
|
if ret < 0 {
|
||||||
|
return "", MakeGitError(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
return C.GoString(buf.ptr), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConfigFindSystem() (string, error) {
|
||||||
|
var buf C.git_buf
|
||||||
|
defer C.git_buf_free(&buf)
|
||||||
|
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
ret := C.git_config_find_system(&buf)
|
||||||
|
if ret < 0 {
|
||||||
|
return "", MakeGitError(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
return C.GoString(buf.ptr), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConfigFindXDG() (string, error) {
|
||||||
|
var buf C.git_buf
|
||||||
|
defer C.git_buf_free(&buf)
|
||||||
|
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
ret := C.git_config_find_xdg(&buf)
|
||||||
|
if ret < 0 {
|
||||||
|
return "", MakeGitError(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
return C.GoString(buf.ptr), nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue