func (o *CheckoutOptions) Validate() error {
	if !o.Create && !o.Hash.IsZero() && o.Branch != "" {
		return ErrBranchHashExclusive
	}
	if o.Create && o.Branch == "" {
		return ErrCreateRequiresBranch
	}
	if o.Branch == "" {
		o.Branch = plumbing.Master
	}
	return nil
}
Validate validates the fields and sets the default values.
package git
import (
	"errors"
	"gopkg.in/src-d/go-git.v4/config"
	"gopkg.in/src-d/go-git.v4/plumbing"
	"gopkg.in/src-d/go-git.v4/plumbing/object"
	"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/sideband"
	"gopkg.in/src-d/go-git.v4/plumbing/transport"
)
type SubmoduleRescursivity uint
const (
	DefaultRemoteName = "origin"
	NoRecurseSubmodules SubmoduleRescursivity = 0
	DefaultSubmoduleRecursionDepth SubmoduleRescursivity = 10
)
var (
	ErrMissingURL = errors.New("URL field is required")
)
type CloneOptions struct {
	URL string
	Auth transport.AuthMethod
	RemoteName string
	ReferenceName plumbing.ReferenceName
	SingleBranch bool
	Depth int
	RecurseSubmodules SubmoduleRescursivity
	Progress sideband.Progress
	Tags TagMode
}
func (o *CloneOptions) Validate() error {
	if o.URL == "" {
		return ErrMissingURL
	}
	if o.RemoteName == "" {
		o.RemoteName = DefaultRemoteName
	}
	if o.ReferenceName == "" {
		o.ReferenceName = plumbing.HEAD
	}
	if o.Tags == InvalidTagMode {
		o.Tags = AllTags
	}
	return nil
}
type PullOptions struct {
	RemoteName string
	ReferenceName plumbing.ReferenceName
	SingleBranch bool
	Depth int
	Auth transport.AuthMethod
	RecurseSubmodules SubmoduleRescursivity
	Progress sideband.Progress
	Force bool
}
func (o *PullOptions) Validate() error {
	if o.RemoteName == "" {
		o.RemoteName = DefaultRemoteName
	}
	if o.ReferenceName == "" {
		o.ReferenceName = plumbing.HEAD
	}
	return nil
}
type TagMode int
const (
	InvalidTagMode TagMode = iota
	TagFollowing
	AllTags
	NoTags
)
type FetchOptions struct {
	RemoteName string
	RefSpecs   []config.RefSpec
	Depth int
	Auth transport.AuthMethod
	Progress sideband.Progress
	Tags TagMode
	Force bool
}
func (o *FetchOptions) Validate() error {
	if o.RemoteName == "" {
		o.RemoteName = DefaultRemoteName
	}
	if o.Tags == InvalidTagMode {
		o.Tags = TagFollowing
	}
	for _, r := range o.RefSpecs {
		if err := r.Validate(); err != nil {
			return err
		}
	}
	return nil
}
type PushOptions struct {
	RemoteName string
	RefSpecs []config.RefSpec
	Auth transport.AuthMethod
	Progress sideband.Progress
}
func (o *PushOptions) Validate() error {
	if o.RemoteName == "" {
		o.RemoteName = DefaultRemoteName
	}
	if len(o.RefSpecs) == 0 {
		o.RefSpecs = []config.RefSpec{
			config.RefSpec(config.DefaultPushRefSpec),
		}
	}
	for _, r := range o.RefSpecs {
		if err := r.Validate(); err != nil {
			return err
		}
	}
	return nil
}
type SubmoduleUpdateOptions struct {
	Init bool
	NoFetch bool
	RecurseSubmodules SubmoduleRescursivity
	Auth transport.AuthMethod
}
var (
	ErrBranchHashExclusive  = errors.New("Branch and Hash are mutually exclusive")
	ErrCreateRequiresBranch = errors.New("Branch is mandatory when Create is used")
)
type CheckoutOptions struct {
	Hash plumbing.Hash
	Branch plumbing.ReferenceName
	Create bool
	Force bool
}