Implement git_repository_set_config #735

Merged
bc-lee merged 3 commits from feature/732-git-repository-set-config into master 2021-02-03 21:33:04 -06:00
1 changed files with 5 additions and 0 deletions
Showing only changes of commit ade1fdde29 - Show all commits

View File

@ -165,12 +165,17 @@ func (v *Repository) Config() (*Config, error) {
return config, nil return config, nil
} }
// SetConfig sets the configuration file for this repository.
//
// This configuration file will be used for all configuration queries involving
// this repository.
func (v *Repository) SetConfig(c *Config) error { func (v *Repository) SetConfig(c *Config) error {
lhchavez commented 2021-02-02 08:30:08 -06:00 (Migrated from github.com)
Review
// SetConfig sets the configuration file for this repository.
//
// This configuration file will be used for all configuration queries involving
// this repository.
func (v *Repository) SetConfig(c *Config) error {
```suggestion // SetConfig sets the configuration file for this repository. // // This configuration file will be used for all configuration queries involving // this repository. func (v *Repository) SetConfig(c *Config) error { ```
runtime.LockOSThread() runtime.LockOSThread()
defer runtime.UnlockOSThread() defer runtime.UnlockOSThread()
ret := C.git_repository_set_config(v.ptr, c.ptr) ret := C.git_repository_set_config(v.ptr, c.ptr)
runtime.KeepAlive(v) runtime.KeepAlive(v)
lhchavez commented 2021-02-02 08:30:56 -06:00 (Migrated from github.com)
Review
	runtime.KeepAlive(v)
	runtime.KeepAlive(c)

otherwise if c is not used by the caller later, the Go runtime is free to remove it in the middle of the CGO call.

```suggestion runtime.KeepAlive(v) runtime.KeepAlive(c) ``` otherwise if `c` is not used by the caller later, the Go runtime is free to remove it in the middle of the CGO call.
runtime.KeepAlive(c)
if ret < 0 { if ret < 0 {
return MakeGitError(ret) return MakeGitError(ret)
} }