Skip to content

Commit

Permalink
Attach the parent tree when creating Tree()
Browse files Browse the repository at this point in the history
!fixup go-gitea#22177

The only place this function is used so far is in
findReadmeFileInEntries(), so the only visible effect
of this oversight was in an obscure corner: if the
README was in a subfolder and was a symlink that pointed up,
as in .github/README.md -> ../docs/old/setup.md, the
README would fail to render when because FollowLinks()
hit the nil ptree.
  • Loading branch information
kousu committed Feb 14, 2023
1 parent 7b5b739 commit df33253
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/git/tree_entry.go
Expand Up @@ -101,12 +101,13 @@ func (te *TreeEntry) FollowLinks() (*TreeEntry, error) {
return entry, nil
}

// returns the subtree, or nil if this is not a tree
// returns the Tree pointed to by this TreeEntry, or nil if this is not a tree
func (te *TreeEntry) Tree() *Tree {
t, err := te.ptree.repo.getTree(te.ID)
if err != nil {
return nil
}
t.ptree = te.ptree
return t
}

Expand Down

0 comments on commit df33253

Please sign in to comment.