Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

plumbing: format/commitgraph, clean up error handling #1133

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions plumbing/format/commitgraph/commitgraph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ func (s *CommitgraphSuite) TestReencodeInMemory(c *C) {
for i, hash := range index.Hashes() {
node, err := index.GetNodeByIndex(i)
c.Assert(err, IsNil)
err = memoryIndex.Add(hash, node)
c.Assert(err, IsNil)
memoryIndex.Add(hash, node)
}
reader.Close()

Expand Down
4 changes: 2 additions & 2 deletions plumbing/format/commitgraph/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
var (
// ErrUnsupportedVersion is returned by OpenFileIndex when the commit graph
// file version is not supported.
ErrUnsupportedVersion = errors.New("Unsuported version")
ErrUnsupportedVersion = errors.New("Unsupported version")
// ErrUnsupportedHash is returned by OpenFileIndex when the commit graph
// hash function is not supported. Currently only SHA-1 is defined and
// supported
ErrUnsupportedHash = errors.New("Unsuported hash algorithm")
ErrUnsupportedHash = errors.New("Unsupported hash algorithm")
// ErrMalformedCommitGraphFile is returned by OpenFileIndex when the commit
// graph file is corrupted.
ErrMalformedCommitGraphFile = errors.New("Malformed commit graph file")
Expand Down
3 changes: 1 addition & 2 deletions plumbing/format/commitgraph/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +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) error {
func (mi *MemoryIndex) Add(hash plumbing.Hash, node *Node) {
// 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
mi.indexMap[hash] = len(mi.commitData)
mi.commitData = append(mi.commitData, node)
return nil
}