aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortechknowlogick2020-10-02 10:39:14 -0400
committerGitHub2020-10-02 10:39:14 -0400
commit96918a442b4aad63bb28ceb767d49b29ba8c1b22 (patch)
tree0f1bad55421c3b227e5fa8ed16d18f61ff02afa3
parentaa1d9ef6cba71c80170ec8c9ef424cb780fa6481 (diff)
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 <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r--modules/git/tree_blob.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/git/tree_blob.go b/modules/git/tree_blob.go
index 4c5a80cb3..f9fc6db49 100644
--- a/modules/git/tree_blob.go
+++ b/modules/git/tree_blob.go
@@ -9,6 +9,7 @@ import (
"path"
"strings"
+ "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/filemode"
"github.com/go-git/go-git/v5/plumbing/object"
)
@@ -35,6 +36,11 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
if i == len(parts)-1 {
entries, err := tree.ListEntries()
if err != nil {
+ if err == plumbing.ErrObjectNotFound {
+ return nil, ErrNotExist{
+ RelPath: relpath,
+ }
+ }
return nil, err
}
for _, v := range entries {
@@ -45,6 +51,11 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
} else {
tree, err = tree.SubTree(name)
if err != nil {
+ if err == plumbing.ErrObjectNotFound {
+ return nil, ErrNotExist{
+ RelPath: relpath,
+ }
+ }
return nil, err
}
}