summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-03-15 01:09:11 +0100
committerCarlos Martín Nieto <[email protected]>2015-03-15 01:09:11 +0100
commit137c4fc3c838a803dddeb2855e726fc30713fdea (patch)
treecc2bbc371b93ed92d4b2f3a1abc2a62d6d578277 /config.go
parent063bed33a90e7d5b1ece1b6bd1aba04a69a78a28 (diff)
parent76d600f7b3633f78e5f1433c16eba4eddfdad3e0 (diff)
Merge branch 'master' into v22
Diffstat (limited to 'config.go')
-rw-r--r--config.go52
1 files changed, 47 insertions, 5 deletions
diff --git a/config.go b/config.go
index 2965a69..9d25e35 100644
--- a/config.go
+++ b/config.go
@@ -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
+}