Skip to content

Commit e4d129d

Browse files
committed
don't try to interpret treepath as hash
...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 1c3ae6d commit e4d129d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/context/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
695695
}
696696
// For legacy and API support only full commit sha
697697
parts := strings.Split(path, "/")
698-
if len(parts) > 0 && len(parts[0]) == 40 {
698+
if len(parts) > 1 && len(parts[0]) == 40 {
699699
ctx.Repo.TreePath = strings.Join(parts[1:], "/")
700700
return parts[0]
701701
}

0 commit comments

Comments
 (0)