MCPcopy Index your code
hub / github.com/go-git/go-git / Restore

Method Restore

worktree.go:345–367  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

343//
344// Restore with no files specified will return ErrNoRestorePaths.
345func (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.
370func (w *Worktree) Reset(opts *ResetOptions) error {

Callers 4

TestRestoreStagedMethod · 0.80
TestRestoreWorktreeMethod · 0.80
TestRestoreBothMethod · 0.80
mainFunction · 0.80

Calls 2

ResetMethod · 0.95
ValidateMethod · 0.45

Tested by 3

TestRestoreStagedMethod · 0.64
TestRestoreWorktreeMethod · 0.64
TestRestoreBothMethod · 0.64