Skip to content

Commit 618c911

Browse files
authored
Remember to attach the parent tree when converting TreeEntry() -> Tree() (#22902)
!fixup #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.
1 parent 71ee488 commit 618c911

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/git/tree_entry.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ func (te *TreeEntry) FollowLinks() (*TreeEntry, error) {
101101
return entry, nil
102102
}
103103

104-
// returns the subtree, or nil if this is not a tree
104+
// returns the Tree pointed to by this TreeEntry, or nil if this is not a tree
105105
func (te *TreeEntry) Tree() *Tree {
106106
t, err := te.ptree.repo.getTree(te.ID)
107107
if err != nil {
108108
return nil
109109
}
110+
t.ptree = te.ptree
110111
return t
111112
}
112113

0 commit comments

Comments
 (0)