code: func (o *GrepOptions) Validate(w *Worktree) error {
  	if !o.CommitHash.IsZero() && o.ReferenceName != "" {
  		return ErrHashOrReference
  	}
  
  	// If none of CommitHash and ReferenceName are provided, set commit hash of
  	// the repository's head.
  	if o.CommitHash.IsZero() && o.ReferenceName == "" {
  		ref, err := w.r.Head()
  		if err != nil {
  			return err
  		}
  		o.CommitHash = ref.Hash()
  	}
  
  	return nil
  }
docs: // Validate validates the fields and sets the default values.