diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-10-26 20:08:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-26 20:08:45 +0000 |
commit | c66f495b35b12c6827507b9933b39a10fa94379b (patch) | |
tree | aeae5054df4a0ba635ddf77743d7ee449f79cf17 /storage/filesystem/config.go | |
parent | 61f0188edcea55dbcfa1c3a35da0c34fed10fd54 (diff) | |
download | go-git-c66f495b35b12c6827507b9933b39a10fa94379b.tar.gz |
storage: filesystem fix config on new repositories (#100)
Diffstat (limited to 'storage/filesystem/config.go')
-rw-r--r-- | storage/filesystem/config.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/storage/filesystem/config.go b/storage/filesystem/config.go index 84252eb..ba7e40b 100644 --- a/storage/filesystem/config.go +++ b/storage/filesystem/config.go @@ -1,6 +1,8 @@ package filesystem import ( + "os" + "gopkg.in/src-d/go-git.v4/config" gitconfig "gopkg.in/src-d/go-git.v4/formats/config" "gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit" @@ -74,17 +76,21 @@ func (c *ConfigStorage) DeleteRemote(name string) error { } func (c *ConfigStorage) read() (*gitconfig.Config, error) { + cfg := gitconfig.New() + f, err := c.dir.Config() if err != nil { + if os.IsNotExist(err) { + return cfg, nil + } + return nil, err } defer f.Close() - cfg := gitconfig.New() d := gitconfig.NewDecoder(f) - err = d.Decode(cfg) - if err != nil { + if err := d.Decode(cfg); err != nil { return nil, err } @@ -92,7 +98,7 @@ func (c *ConfigStorage) read() (*gitconfig.Config, error) { } func (c *ConfigStorage) write(cfg *gitconfig.Config) error { - f, err := c.dir.Config() + f, err := c.dir.ConfigWriter() if err != nil { return err } |