diff options
author | zeripath <art27@cantab.net> | 2023-01-15 14:35:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-15 14:35:56 +0000 |
commit | f93522ddaed52e036062d98f114a5f42dece2235 (patch) | |
tree | 3aa20399e481436254a0a05407f565fdee85f76a /routers/api/v1/api.go | |
parent | 10c9f96a1eeeaf7be63743a3ab208e53973cb1e9 (diff) | |
download | gitea-f93522ddaed52e036062d98f114a5f42dece2235.tar.gz gitea-f93522ddaed52e036062d98f114a5f42dece2235.zip |
Prevent panic on looking at api "git" endpoints for empty repos (#22457) (#22458)
Backport #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/api.go')
-rw-r--r-- | routers/api/v1/api.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 9f6bcf4f85..b0a864d199 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1042,7 +1042,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) |