Restore restores specified files in the working tree or stage with contents from a restore source. If a path is tracked but does not exist in the restore, source, it will be removed to match the source. If Staged and Worktree are true, then the restore source will be the index. If only Staged is tr
(o *RestoreOptions)
| 343 | // |
| 344 | // Restore with no files specified will return ErrNoRestorePaths. |
| 345 | func (w *Worktree) Restore(o *RestoreOptions) error { |
| 346 | if err := o.Validate(); err != nil { |
| 347 | return err |
| 348 | } |
| 349 | |
| 350 | if o.Staged { |
| 351 | opts := &ResetOptions{ |
| 352 | Files: o.Files, |
| 353 | } |
| 354 | |
| 355 | if o.Worktree { |
| 356 | // If we are doing both Worktree and Staging then it is a hard reset |
| 357 | opts.Mode = HardReset |
| 358 | } else { |
| 359 | // If we are doing just staging then it is a mixed reset |
| 360 | opts.Mode = MixedReset |
| 361 | } |
| 362 | |
| 363 | return w.Reset(opts) |
| 364 | } |
| 365 | |
| 366 | return ErrRestoreWorktreeOnlyNotSupported |
| 367 | } |
| 368 | |
| 369 | // Reset the worktree to a specified state. |
| 370 | func (w *Worktree) Reset(opts *ResetOptions) error { |