Skip to content

Commit f93522d

Browse files
authored
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 <[email protected]>
1 parent 10c9f96 commit f93522d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

routers/api/v1/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ func Routes(ctx gocontext.Context) *web.Route {
10421042
m.Get("/blobs/{sha}", repo.GetBlob)
10431043
m.Get("/tags/{sha}", repo.GetAnnotatedTag)
10441044
m.Get("/notes/{sha}", repo.GetNote)
1045-
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode))
1045+
}, context.ReferencesGitRepo(true), reqRepoReader(unit.TypeCode))
10461046
m.Post("/diffpatch", reqRepoWriter(unit.TypeCode), reqToken(), bind(api.ApplyDiffPatchFileOptions{}), repo.ApplyDiffPatch)
10471047
m.Group("/contents", func() {
10481048
m.Get("", repo.GetContentsList)

0 commit comments

Comments
 (0)