summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorCalin Seciu <[email protected]>2016-02-20 14:52:57 +0200
committerCalin Seciu <[email protected]>2016-02-20 14:52:57 +0200
commitc6f394e407a8f119eea191e1321f61828921f164 (patch)
tree6b4ab4bbd263388f0384b029b2a770189782b9d0 /config.go
parentdc4409793db0205ce7c0783a10363d7d67aee674 (diff)
parent251d89e1d41037185df0ea89e9aab208efc40d4e (diff)
Merge branch 'next' into stash-support
Diffstat (limited to 'config.go')
-rw-r--r--config.go29
1 files changed, 26 insertions, 3 deletions
diff --git a/config.go b/config.go
index 9d25e35..7408fbc 100644
--- a/config.go
+++ b/config.go
@@ -12,6 +12,9 @@ import (
type ConfigLevel int
const (
+ // System-wide on Windows, for compatibility with portable git
+ ConfigLevelProgramdata ConfigLevel = C.GIT_CONFIG_LEVEL_PROGRAMDATA
+
// System-wide configuration file; /etc/gitconfig on Linux systems
ConfigLevelSystem ConfigLevel = C.GIT_CONFIG_LEVEL_SYSTEM
@@ -115,18 +118,20 @@ func (c *Config) LookupInt64(name string) (int64, error) {
}
func (c *Config) LookupString(name string) (string, error) {
- var ptr *C.char
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
+ valBuf := C.git_buf{}
+
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- if ret := C.git_config_get_string(&ptr, c.ptr, cname); ret < 0 {
+ if ret := C.git_config_get_string_buf(&valBuf, c.ptr, cname); ret < 0 {
return "", MakeGitError(ret)
}
+ defer C.git_buf_free(&valBuf)
- return C.GoString(ptr), nil
+ return C.GoString(valBuf.ptr), nil
}
func (c *Config) LookupBool(name string) (bool, error) {
@@ -410,3 +415,21 @@ func ConfigFindXDG() (string, error) {
return C.GoString(buf.ptr), nil
}
+
+// ConfigFindProgramdata locate the path to the configuration file in ProgramData.
+//
+// Look for the file in %PROGRAMDATA%\Git\config used by portable git.
+func ConfigFindProgramdata() (string, error) {
+ var buf C.git_buf
+ defer C.git_buf_free(&buf)
+
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ ret := C.git_config_find_programdata(&buf)
+ if ret < 0 {
+ return "", MakeGitError(ret)
+ }
+
+ return C.GoString(buf.ptr), nil
+}