From 2123c530503c3b70cc223f5efa77bce265133d26 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 25 Apr 2019 08:41:56 +0200 Subject: plumbing: format/commitgraph, rename structs/fields to follow the terms used by git more closely Signed-off-by: Filip Navara --- plumbing/format/commitgraph/memory.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'plumbing/format/commitgraph/memory.go') diff --git a/plumbing/format/commitgraph/memory.go b/plumbing/format/commitgraph/memory.go index 1d57a07..f084b85 100644 --- a/plumbing/format/commitgraph/memory.go +++ b/plumbing/format/commitgraph/memory.go @@ -5,7 +5,7 @@ import ( ) type MemoryIndex struct { - commitData []*Node + commitData []*CommitData indexMap map[plumbing.Hash]int } @@ -26,28 +26,28 @@ func (mi *MemoryIndex) GetIndexByHash(h plumbing.Hash) (int, error) { return 0, plumbing.ErrObjectNotFound } -// GetNodeByIndex gets the commit node from the commit graph using index +// GetCommitDataByIndex gets the commit node from the commit graph using index // obtained from child node, if available -func (mi *MemoryIndex) GetNodeByIndex(i int) (*Node, error) { +func (mi *MemoryIndex) GetCommitDataByIndex(i int) (*CommitData, error) { if int(i) >= len(mi.commitData) { return nil, plumbing.ErrObjectNotFound } - node := mi.commitData[i] + commitData := mi.commitData[i] // Map parent hashes to parent indexes - if node.ParentIndexes == nil { - parentIndexes := make([]int, len(node.ParentHashes)) - for i, parentHash := range node.ParentHashes { + if commitData.ParentIndexes == nil { + parentIndexes := make([]int, len(commitData.ParentHashes)) + for i, parentHash := range commitData.ParentHashes { var err error if parentIndexes[i], err = mi.GetIndexByHash(parentHash); err != nil { return nil, err } } - node.ParentIndexes = parentIndexes + commitData.ParentIndexes = parentIndexes } - return node, nil + return commitData, nil } // Hashes returns all the hashes that are available in the index @@ -60,11 +60,11 @@ func (mi *MemoryIndex) Hashes() []plumbing.Hash { } // Add adds new node to the memory index -func (mi *MemoryIndex) Add(hash plumbing.Hash, node *Node) { +func (mi *MemoryIndex) Add(hash plumbing.Hash, commitData *CommitData) { // The parent indexes are calculated lazily in GetNodeByIndex // which allows adding nodes out of order as long as all parents // are eventually resolved - node.ParentIndexes = nil + commitData.ParentIndexes = nil mi.indexMap[hash] = len(mi.commitData) - mi.commitData = append(mi.commitData, node) + mi.commitData = append(mi.commitData, commitData) } -- cgit