Skip to content

Commit

Permalink
Prevent panic on looking at api "git" endpoints for empty repos (go-g…
Browse files Browse the repository at this point in the history
…itea#22457)

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]>
  • Loading branch information
zeripath authored Jan 15, 2023
1 parent fe519d8 commit cc1f8cb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ func Routes(ctx gocontext.Context) *web.Route {
m.Get("/blobs/{sha}", repo.GetBlob)
m.Get("/tags/{sha}", repo.GetAnnotatedTag)
m.Get("/notes/{sha}", repo.GetNote)
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode))
}, context.ReferencesGitRepo(true), reqRepoReader(unit.TypeCode))
m.Post("/diffpatch", reqRepoWriter(unit.TypeCode), reqToken(), bind(api.ApplyDiffPatchFileOptions{}), repo.ApplyDiffPatch)
m.Group("/contents", func() {
m.Get("", repo.GetContentsList)
Expand Down

0 comments on commit cc1f8cb

Please sign in to comment.