Skip to content

Commit bcf6e82

Browse files
noerwlunny
authored andcommitted
don't try to interpret treepath as hash (go-gitea#17272)
...when path contains no hash-path-separator ('/') This is a workaround to go-gitea#17179. Entering this case when `path` does not contain a '/' does not really make sense, as that means the tree path is empty, but this case is only entered for routes that expect a non-empty tree path. Treepaths like <40-char-dirname>/<filename> will still fail, but hopefully don't occur that often. A more complete fix that avoids this case too is outlined in go-gitea#17185, but too big of a change to backport
1 parent 7cf611d commit bcf6e82

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

services/context/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ func getRefName(ctx *Base, repo *Repository, pathType RepoRefType) string {
823823
// For legacy and API support only full commit sha
824824
parts := strings.Split(path, "/")
825825

826-
if len(parts) > 0 && len(parts[0]) == git.ObjectFormatFromName(repo.Repository.ObjectFormatName).FullLength() {
826+
if len(parts) > 1 && len(parts[0]) == git.ObjectFormatFromName(repo.Repository.ObjectFormatName).FullLength() {
827827
repo.TreePath = strings.Join(parts[1:], "/")
828828
return parts[0]
829829
}

0 commit comments

Comments
 (0)