Skip to content

Commit 96918a4

Browse files
techknowlogickzeripathlunny
authored
Fix 500 on README in submodule (#13006) (#13016)
If a README file is a symlink to a submodule Gitea the view branch page will return a 500. The underlying problem is a missed conversion of an plumbing.ErrObjectNotFound in git/tree_blob.go. Fix #12599 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: zeripath <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent aa1d9ef commit 96918a4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

modules/git/tree_blob.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"path"
1010
"strings"
1111

12+
"github.com/go-git/go-git/v5/plumbing"
1213
"github.com/go-git/go-git/v5/plumbing/filemode"
1314
"github.com/go-git/go-git/v5/plumbing/object"
1415
)
@@ -35,6 +36,11 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
3536
if i == len(parts)-1 {
3637
entries, err := tree.ListEntries()
3738
if err != nil {
39+
if err == plumbing.ErrObjectNotFound {
40+
return nil, ErrNotExist{
41+
RelPath: relpath,
42+
}
43+
}
3844
return nil, err
3945
}
4046
for _, v := range entries {
@@ -45,6 +51,11 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
4551
} else {
4652
tree, err = tree.SubTree(name)
4753
if err != nil {
54+
if err == plumbing.ErrObjectNotFound {
55+
return nil, ErrNotExist{
56+
RelPath: relpath,
57+
}
58+
}
4859
return nil, err
4960
}
5061
}

0 commit comments

Comments
 (0)