func (c *Config) Unmarshal(b []byte) error {
	r := bytes.NewBuffer(b)
	d := format.NewDecoder(r)
	c.Raw = format.New()
	if err := d.Decode(c.Raw); err != nil {
		return err
	}
	c.unmarshalCore()
	if err := c.unmarshalPack(); err != nil {
		return err
	}
	unmarshalSubmodules(c.Raw, c.Submodules)
	if err := c.unmarshalBranches(); err != nil {
		return err
	}
	return c.unmarshalRemotes()
}
Unmarshal parses a git-config file and stores it.
package config
import (
	"bytes"
	"errors"
	"fmt"
	"sort"
	"strconv"
	"gopkg.in/src-d/go-git.v4/internal/url"
	format "gopkg.in/src-d/go-git.v4/plumbing/format/config"
)
const (
	DefaultFetchRefSpec = "+refs/heads/*:refs/remotes/%s/*"
	DefaultPushRefSpec = "refs/heads/*:refs/heads/*"
)
type ConfigStorer interface {
	Config() (*Config, error)
	SetConfig(*Config) error
}
var (
	ErrInvalid               = errors.New("config invalid key in remote or branch")
	ErrRemoteConfigNotFound  = errors.New("remote config not found")
	ErrRemoteConfigEmptyURL  = errors.New("remote config: empty URL")
	ErrRemoteConfigEmptyName = errors.New("remote config: empty name")
)
type Config struct {
	Core struct {
		IsBare bool
		Worktree string
		CommentChar string
	}
	Pack struct {
		Window uint
	}
	Remotes map[string]*RemoteConfig
	Submodules map[string]*Submodule
	Branches map[string]*Branch
	Raw *format.Config
}
func NewConfig() *Config {
	config := &Config{
		Remotes:    make(map[string]*RemoteConfig),
		Submodules: make(map[string]*Submodule),
		Branches:   make(map[string]*Branch),
		Raw:        format.New(),
	}
	config.Pack.Window = DefaultPackWindow
	return config
}
func (c *Config) Validate() error {
	for name, r := range c.Remotes {
		if r.Name != name {
			return ErrInvalid
		}
		if err := r.Validate(); err != nil {
			return err
		}
	}
	for name, b := range c.Branches {
		if b.Name != name {
			return ErrInvalid
		}
		if err := b.Validate(); err != nil {
			return err
		}
	}
	return nil
}
const (
	remoteSection    = "remote"
	submoduleSection = "submodule"
	branchSection    = "branch"
	coreSection      = "core"
	packSection      = "pack"
	fetchKey         = "fetch"
	urlKey           = "url"
	bareKey          = "bare"
	worktreeKey      = "worktree"
	commentCharKey   = "commentChar"
	windowKey        = "window"
	mergeKey         = "merge"
	DefaultPackWindow = uint(10)
)