Skip to content

Commit

Permalink
Remember to attach the parent tree when converting TreeEntry() -> Tre…
Browse files Browse the repository at this point in the history
…e() (#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.
  • Loading branch information
kousu authored Feb 14, 2023
1 parent 71ee488 commit 618c911
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/git/tree_entry.go
Original file line number Diff line number Diff line change
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 618c911

Please sign in to comment.