summaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2023-01-15 14:33:25 +0000
committerGitHub <noreply@github.com>2023-01-15 08:33:25 -0600
commitcc1f8cbe96c195aab79761c48bc4ec0bff2b3431 (patch)
treebfa1c89fc7fa14626a193718a80fa6327ccb77e6 /routers/api/v1
parentfe519d86338761b91ff1702b70008895ef89f7eb (diff)
downloadgitea-cc1f8cbe96c195aab79761c48bc4ec0bff2b3431.tar.gz
gitea-cc1f8cbe96c195aab79761c48bc4ec0bff2b3431.zip
Prevent panic on looking at api "git" endpoints for empty repos (#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 #22452 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/api.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index c12ceacdd3..d5a12ead85 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -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)