(commit plumbing.Hash)
| 537 | } |
| 538 | |
| 539 | func (w *Worktree) setHEADCommit(commit plumbing.Hash) error { |
| 540 | head, err := w.r.Reference(plumbing.HEAD, false) |
| 541 | if err != nil { |
| 542 | return err |
| 543 | } |
| 544 | |
| 545 | if head.Type() == plumbing.HashReference { |
| 546 | head = plumbing.NewHashReference(plumbing.HEAD, commit) |
| 547 | return w.r.Storer.SetReference(head) |
| 548 | } |
| 549 | |
| 550 | branch, err := w.r.Reference(head.Target(), false) |
| 551 | if err != nil { |
| 552 | return err |
| 553 | } |
| 554 | |
| 555 | if !branch.Name().IsBranch() { |
| 556 | return fmt.Errorf("invalid HEAD target should be a branch, found %s", branch.Type()) |
| 557 | } |
| 558 | |
| 559 | branch = plumbing.NewHashReference(branch.Name(), commit) |
| 560 | return w.r.Storer.SetReference(branch) |
| 561 | } |
| 562 | |
| 563 | func (w *Worktree) checkoutChangeSubmodule(name string, |
| 564 | a merkletrie.Action, |
no test coverage detected