Validate validates the fields and sets the default values.
()
| 368 | |
| 369 | // Validate validates the fields and sets the default values. |
| 370 | func (o *CheckoutOptions) Validate() error { |
| 371 | if !o.Create && !o.Hash.IsZero() && o.Branch != "" { |
| 372 | return ErrBranchHashExclusive |
| 373 | } |
| 374 | |
| 375 | if o.Create && o.Branch == "" { |
| 376 | return ErrCreateRequiresBranch |
| 377 | } |
| 378 | |
| 379 | if o.Branch == "" { |
| 380 | o.Branch = plumbing.Master |
| 381 | } |
| 382 | |
| 383 | return nil |
| 384 | } |
| 385 | |
| 386 | // ResetMode defines the mode of a reset operation. |
| 387 | type ResetMode int8 |