Compare commits
1 Commits
main
...
cmn/config
Author | SHA1 | Date |
---|---|---|
|
785b6024cf |
16
config.go
16
config.go
|
@ -354,6 +354,22 @@ func (c *Config) Refresh() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Snapshot creates an immutable snapshot from the configuration. This
|
||||||
|
// means that reads over multiple values will reflect the same version
|
||||||
|
// of the configuration files
|
||||||
|
func (c *Config) Snapshot() (*Config, error) {
|
||||||
|
config := new(Config)
|
||||||
|
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
if ret := C.git_config_snapshot(&config.ptr, c.ptr); ret < 0 {
|
||||||
|
return nil, MakeGitError(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
type ConfigIterator struct {
|
type ConfigIterator struct {
|
||||||
ptr *C.git_config_iterator
|
ptr *C.git_config_iterator
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,22 @@ func (v *Repository) Config() (*Config, error) {
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConfigSnapshot returns a configuration snapshot from the
|
||||||
|
// repository. This is the preferred form when not changing the
|
||||||
|
// configuration.
|
||||||
|
func (v *Repository) ConfigSnapshot() (*Config, error) {
|
||||||
|
config := new(Config)
|
||||||
|
|
||||||
|
runtime.LockOSThread()
|
||||||
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
|
if ret := C.git_repository_config_snapshot(&config.ptr, v.ptr); ret < 0 {
|
||||||
|
return nil, MakeGitError(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (v *Repository) Index() (*Index, error) {
|
func (v *Repository) Index() (*Index, error) {
|
||||||
var ptr *C.git_index
|
var ptr *C.git_index
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue