(commit plumbing.Hash)
| 559 | } |
| 560 | |
| 561 | func (w *Worktree) setHEADCommit(commit plumbing.Hash) error { |
| 562 | head, err := w.r.Reference(plumbing.HEAD, false) |
| 563 | if err != nil { |
| 564 | return err |
| 565 | } |
| 566 | |
| 567 | if head.Type() == plumbing.HashReference { |
| 568 | head = plumbing.NewHashReference(plumbing.HEAD, commit) |
| 569 | return w.r.Storer.SetReference(head) |
| 570 | } |
| 571 | |
| 572 | branch, err := w.r.Reference(head.Target(), false) |
| 573 | if err != nil { |
| 574 | return err |
| 575 | } |
| 576 | |
| 577 | if !branch.Name().IsBranch() { |
| 578 | return fmt.Errorf("invalid HEAD target should be a branch, found %s", branch.Type()) |
| 579 | } |
| 580 | |
| 581 | branch = plumbing.NewHashReference(branch.Name(), commit) |
| 582 | return w.r.Storer.SetReference(branch) |
| 583 | } |
| 584 | |
| 585 | func (w *Worktree) checkoutChangeSubmodule(name string, |
| 586 | a merkletrie.Action, |
no test coverage detected