Skip to content

Commit a107e18

Browse files
committed
Repository.SetConfig, shortcut to Repository.Storer.SetConfig
1 parent 86c0c01 commit a107e18

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

repository.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,20 @@ func cleanUpDir(path string, all bool) error {
435435
return err
436436
}
437437

438-
// Config return the repository config
438+
// Config return the repository config. In a filesystem backed repository this
439+
// means read the `.git/config`.
439440
func (r *Repository) Config() (*config.Config, error) {
440441
return r.Storer.Config()
441442
}
442443

444+
// SetConfig marshall and writes the repository config. In a filesystem backed
445+
// repository this means write the `.git/config`. This function should be called
446+
// with the result of `Repository.Config` and never with the output of
447+
// `Repository.ConfigScoped`.
448+
func (r *Repository) SetConfig(cfg *config.Config) error {
449+
return r.Storer.SetConfig(cfg)
450+
}
451+
443452
// ConfigScoped returns the repository config, merged with requested scope and
444453
// lower. For example if, config.GlobalScope is given the local and global config
445454
// are returned merged in one config value.

0 commit comments

Comments
 (0)