(t *object.Tree, files []string)
| 444 | } |
| 445 | |
| 446 | func (w *Worktree) resetWorktree(t *object.Tree, files []string) error { |
| 447 | changes, err := w.diffStagingWithWorktree(true, false) |
| 448 | if err != nil { |
| 449 | return err |
| 450 | } |
| 451 | |
| 452 | idx, err := w.r.Storer.Index() |
| 453 | if err != nil { |
| 454 | return err |
| 455 | } |
| 456 | b := newIndexBuilder(idx) |
| 457 | |
| 458 | filesMap := buildFilePathMap(files) |
| 459 | for _, ch := range changes { |
| 460 | if len(files) > 0 { |
| 461 | file := "" |
| 462 | if ch.From != nil { |
| 463 | file = ch.From.String() |
| 464 | } else if ch.To != nil { |
| 465 | file = ch.To.String() |
| 466 | } |
| 467 | |
| 468 | if file == "" { |
| 469 | continue |
| 470 | } |
| 471 | |
| 472 | contains := inFiles(filesMap, file) |
| 473 | if !contains { |
| 474 | continue |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | if err := w.checkoutChange(ch, t, b); err != nil { |
| 479 | return err |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | b.Write(idx) |
| 484 | return w.r.Storer.SetIndex(idx) |
| 485 | } |
| 486 | |
| 487 | func (w *Worktree) checkoutChange(ch merkletrie.Change, t *object.Tree, idx *indexBuilder) error { |
| 488 | a, err := ch.Action() |
no test coverage detected