Skip to content

Commit cc1f8cb

Browse files
authored
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>
1 parent fe519d8 commit cc1f8cb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: routers/api/v1/api.go

+1-1
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)