From df33253c5dcf2150f9339fa7574e4d7d2ba650a5 Mon Sep 17 00:00:00 2001 From: Nick Guenther Date: Mon, 13 Feb 2023 23:20:42 -0500 Subject: [PATCH] Attach the parent tree when creating Tree() !fixup https://github.com/go-gitea/gitea/pull/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. --- modules/git/tree_entry.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/git/tree_entry.go b/modules/git/tree_entry.go index c4085c0278f33..95131214872e6 100644 --- a/modules/git/tree_entry.go +++ b/modules/git/tree_entry.go @@ -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 }