aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/config.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-05-24 09:15:51 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2020-05-24 09:15:51 +0200
commitc80979499a2177f3e172b6d89dabaa0bf64e81d1 (patch)
tree53b50491cc72557cabc436f2784590cf449228d0 /storage/filesystem/config.go
parent936faa404ef02c88bde6a62663a6e1a4831c1fb3 (diff)
downloadgo-git-c80979499a2177f3e172b6d89dabaa0bf64e81d1.tar.gz
Revert "Merge pull request #20 from quorumcontrol/feature/other-configs"
This reverts commit 3127ad9a44a2ee935502816065dfe39f494f583d, reversing changes made to 73c52edaad2dae256be61bd1dbbab08e1092f58e.
Diffstat (limited to 'storage/filesystem/config.go')
-rw-r--r--storage/filesystem/config.go52
1 files changed, 4 insertions, 48 deletions
diff --git a/storage/filesystem/config.go b/storage/filesystem/config.go
index dbdce54..01b35b4 100644
--- a/storage/filesystem/config.go
+++ b/storage/filesystem/config.go
@@ -5,7 +5,6 @@ import (
"os"
"github.com/go-git/go-git/v5/config"
- format "github.com/go-git/go-git/v5/plumbing/format/config"
"github.com/go-git/go-git/v5/storage/filesystem/dotgit"
"github.com/go-git/go-git/v5/utils/ioutil"
)
@@ -14,11 +13,10 @@ type ConfigStorage struct {
dir *dotgit.DotGit
}
-func (c *ConfigStorage) Config() (*config.Config, error) {
+func (c *ConfigStorage) Config() (conf *config.Config, err error) {
cfg := config.NewConfig()
- // local config (./.git/config)
- f, err := c.dir.LocalConfig()
+ f, err := c.dir.Config()
if err != nil {
if os.IsNotExist(err) {
return cfg, nil
@@ -31,55 +29,13 @@ func (c *ConfigStorage) Config() (*config.Config, error) {
b, err := stdioutil.ReadAll(f)
if err != nil {
- return cfg, err
- }
-
- if err = cfg.UnmarshalScoped(format.LocalScope, b); err != nil {
- return cfg, err
- }
-
- // global config (~/.gitconfig)
- f, err = c.dir.GlobalConfig()
- if err != nil {
- if os.IsNotExist(err) {
- return cfg, nil
- }
-
return nil, err
}
- defer ioutil.CheckClose(f, &err)
-
- b, err = stdioutil.ReadAll(f)
- if err != nil {
- return cfg, err
- }
-
- if err = cfg.UnmarshalScoped(format.GlobalScope, b); err != nil {
- return cfg, err
- }
-
- // system config (/etc/gitconfig)
- f, err = c.dir.SystemConfig()
- if err != nil {
- if os.IsNotExist(err) {
- return cfg, nil
- }
-
+ if err = cfg.Unmarshal(b); err != nil {
return nil, err
}
- defer ioutil.CheckClose(f, &err)
-
- b, err = stdioutil.ReadAll(f)
- if err != nil {
- return cfg, err
- }
-
- if err = cfg.UnmarshalScoped(format.SystemScope, b); err != nil {
- return cfg, err
- }
-
return cfg, err
}
@@ -88,7 +44,7 @@ func (c *ConfigStorage) SetConfig(cfg *config.Config) (err error) {
return err
}
- f, err := c.dir.LocalConfigWriter()
+ f, err := c.dir.ConfigWriter()
if err != nil {
return err
}