Browse Source

Remember to attach the parent tree when converting TreeEntry() -> Tree() (#22902)

!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 README-related 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 FollowLinks()
hit the nil ptree. This makes the ptree non-nil and thus repairs it.
tags/v1.19.0-rc0
Nick 1 year ago
parent
commit
618c9118c1
No account linked to committer's email address
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      modules/git/tree_entry.go

+ 2
- 1
modules/git/tree_entry.go View File

@@ -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
}


Loading…
Cancel
Save