Skip to content

Commit c56b33f

Browse files
committed
Prevent panic on looking at api "git" endpoints for empty repos
The API endpoints for "git" can panic if they are called on an empty repo. We can simply allow empty repos for these endpoints without worry as they should just work. Fix go-gitea#22452 Signed-off-by: Andrew Thornton <[email protected]>
1 parent fe519d8 commit c56b33f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

routers/api/v1/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ func Routes(ctx gocontext.Context) *web.Route {
10611061
m.Get("/blobs/{sha}", repo.GetBlob)
10621062
m.Get("/tags/{sha}", repo.GetAnnotatedTag)
10631063
m.Get("/notes/{sha}", repo.GetNote)
1064-
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode))
1064+
}, context.ReferencesGitRepo(true), reqRepoReader(unit.TypeCode))
10651065
m.Post("/diffpatch", reqRepoWriter(unit.TypeCode), reqToken(), bind(api.ApplyDiffPatchFileOptions{}), repo.ApplyDiffPatch)
10661066
m.Group("/contents", func() {
10671067
m.Get("", repo.GetContentsList)

0 commit comments

Comments
 (0)