code: func (o *CommitOptions) Validate(r *Repository) error {
  	if o.Author == nil {
  		return ErrMissingAuthor
  	}
  
  	if o.Committer == nil {
  		o.Committer = o.Author
  	}
  
  	if len(o.Parents) == 0 {
  		head, err := r.Head()
  		if err != nil && err != plumbing.ErrReferenceNotFound {
  			return err
  		}
  
  		if head != nil {
  			o.Parents = []plumbing.Hash{head.Hash()}
  		}
  	}
  
  	return nil
  }
docs: // Validate validates the fields and sets the default values.