Record that the specified `oid` is the specified `commit`.
(oid git.OID, commit *git.Commit)
| 651 | |
| 652 | // Record that the specified `oid` is the specified `commit`. |
| 653 | func (g *Graph) RegisterCommit(oid git.OID, commit *git.Commit) { |
| 654 | g.commitLock.Lock() |
| 655 | if _, ok := g.commitSizes[oid]; ok { |
| 656 | panic(fmt.Sprintf("commit %s registered twice!", oid)) |
| 657 | } |
| 658 | g.commitLock.Unlock() |
| 659 | |
| 660 | // The number of direct parents of this commit. |
| 661 | parentCount := counts.NewCount32(uint64(len(commit.Parents))) |
| 662 | |
| 663 | // The size of the items we know so far: |
| 664 | size := CommitSize{} |
| 665 | |
| 666 | // The tree: |
| 667 | treeSize := g.GetTreeSize(commit.Tree) |
| 668 | size.addTree(treeSize) |
| 669 | |
| 670 | for _, parent := range commit.Parents { |
| 671 | parentSize := g.GetCommitSize(parent) |
| 672 | size.addParent(parentSize) |
| 673 | } |
| 674 | |
| 675 | // Add 1 for this commit itself: |
| 676 | size.MaxAncestorDepth.Increment(1) |
| 677 | |
| 678 | g.commitLock.Lock() |
| 679 | g.commitSizes[oid] = size |
| 680 | g.commitLock.Unlock() |
| 681 | |
| 682 | g.historyLock.Lock() |
| 683 | g.historySize.recordCommit(g, oid, size, commit.Size, parentCount) |
| 684 | g.historyLock.Unlock() |
| 685 | } |
| 686 | |
| 687 | func (g *Graph) RequireTagSize(oid git.OID, listener func(TagSize)) (TagSize, bool) { |
| 688 | g.tagLock.Lock() |
no test coverage detected