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

fix panic in object.Tree.FindEntry #1095

Merged
merged 1 commit into from
Apr 2, 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
2 changes: 1 addition & 1 deletion plumbing/object/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (t *Tree) FindEntry(path string) (*TreeEntry, error) {
pathCurrent := ""

// search for the longest path in the tree path cache
for i := len(pathParts); i > 1; i-- {
for i := len(pathParts) - 1; i > 1; i-- {
path := filepath.Join(pathParts[:i]...)

tree, ok := t.t[path]
Expand Down
3 changes: 3 additions & 0 deletions plumbing/object/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func (s *TreeSuite) TestFindEntryNotFound(c *C) {
e, err := s.Tree.FindEntry("not-found")
c.Assert(e, IsNil)
c.Assert(err, Equals, ErrEntryNotFound)
e, err = s.Tree.FindEntry("not-found/not-found/not-found")
c.Assert(e, IsNil)
c.Assert(err, Equals, ErrDirectoryNotFound)
}

// Overrides returned plumbing.EncodedObject for given hash.
Expand Down