diff options
| author | Tarrant Rollins <[email protected]> | 2015-01-13 19:48:45 -0800 |
|---|---|---|
| committer | Tarrant Rollins <[email protected]> | 2015-01-14 13:38:35 -0800 |
| commit | 548bb9b5e9161fe876eeb3c23ceae061840cb532 (patch) | |
| tree | 5afb6cd853fbcb2ef50fbbc33b17ee4197991042 /config.go | |
| parent | 57412d0293fa4d84bab60590aa9e4589f706ff0a (diff) | |
Add Go functions for git_config_find_* functions
ConfigFindGlobal -> git_config_find_global
ConfigFindSystem -> git_config_find_system
ConfigFindXDG -> git_config_find_xdg
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 52 |
1 files changed, 47 insertions, 5 deletions
@@ -35,14 +35,14 @@ const ( ) type ConfigEntry struct { - Name string + Name string Value string Level ConfigLevel } func newConfigEntryFromC(centry *C.git_config_entry) *ConfigEntry { return &ConfigEntry{ - Name: C.GoString(centry.name), + Name: C.GoString(centry.name), Value: C.GoString(centry.value), Level: ConfigLevel(centry.level), } @@ -74,7 +74,6 @@ func (c *Config) AddFile(path string, level ConfigLevel, force bool) error { 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) @@ -130,7 +129,6 @@ func (c *Config) LookupString(name string) (string, error) { return C.GoString(ptr), nil } - func (c *Config) LookupBool(name string) (bool, error) { var out C.int cname := C.CString(name) @@ -234,7 +232,6 @@ func (c *Config) SetInt32(name string, value int32) (err error) { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) - runtime.LockOSThread() defer runtime.UnlockOSThread() @@ -368,3 +365,48 @@ func (iter *ConfigIterator) Free() { runtime.SetFinalizer(iter, nil) 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 +} |
