mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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>
This commit is contained in:
		@@ -9,6 +9,7 @@ import (
 | 
				
			|||||||
	"path"
 | 
						"path"
 | 
				
			||||||
	"strings"
 | 
						"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/filemode"
 | 
				
			||||||
	"github.com/go-git/go-git/v5/plumbing/object"
 | 
						"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 {
 | 
							if i == len(parts)-1 {
 | 
				
			||||||
			entries, err := tree.ListEntries()
 | 
								entries, err := tree.ListEntries()
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
 | 
									if err == plumbing.ErrObjectNotFound {
 | 
				
			||||||
 | 
										return nil, ErrNotExist{
 | 
				
			||||||
 | 
											RelPath: relpath,
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				return nil, err
 | 
									return nil, err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			for _, v := range entries {
 | 
								for _, v := range entries {
 | 
				
			||||||
@@ -45,6 +51,11 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
 | 
				
			|||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			tree, err = tree.SubTree(name)
 | 
								tree, err = tree.SubTree(name)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
 | 
									if err == plumbing.ErrObjectNotFound {
 | 
				
			||||||
 | 
										return nil, ErrNotExist{
 | 
				
			||||||
 | 
											RelPath: relpath,
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				return nil, err
 | 
									return nil, err
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user