88 "fmt"
99 "net/http"
1010 "path"
11- "strings"
1211
1312 git_model "code.gitea.io/gitea/models/git"
1413 access_model "code.gitea.io/gitea/models/perm/access"
@@ -167,27 +166,20 @@ func updateEditRepositoryIsEmpty(ctx *context.Context, editRepo *repo_model.Repo
167166 return
168167 }
169168
170- editGitRepo , err := gitrepo .OpenRepository (git . DefaultContext , editRepo )
169+ editGitRepo , err := gitrepo .OpenRepository (ctx , editRepo )
171170 if err != nil {
172171 log .Error ("gitrepo.OpenRepository: %v" , err )
173172 return
174173 }
175- if editGitRepo == nil {
176- return
177- }
174+ defer editGitRepo .Close ()
178175
179176 if isEmpty , err := editGitRepo .IsEmpty (); err == nil && ! isEmpty {
180177 _ = repo_model .UpdateRepositoryCols (ctx , & repo_model.Repository {ID : editRepo .ID , IsEmpty : false }, "is_empty" )
181178 }
182- editGitRepo .Close ()
183179}
184180
185181func forkToEditFileCommon (ctx * context.Context , editOperation , treePath string , notEditableMessage any ) {
186- // Check if the filename (and additional path) is specified in the querystring
187- // (filename is a misnomer, but kept for compatibility with GitHub)
188- filePath , _ := path .Split (ctx .Req .URL .Query ().Get ("filename" ))
189- filePath = strings .Trim (filePath , "/" )
190- treeNames , treePaths := getParentTreeFields (path .Join (ctx .Repo .TreePath , filePath ))
182+ treeNames , treePaths := getParentTreeFields (treePath )
191183
192184 ctx .Data ["EditOperation" ] = editOperation
193185 ctx .Data ["TreePath" ] = treePath
@@ -202,8 +194,6 @@ func ForkToEditFilePost(ctx *context.Context) {
202194
203195 editRepo , notEditableMessage := getEditRepository (ctx )
204196
205- ctx .Data ["PageHasPosted" ] = true
206-
207197 // Fork repository, if it doesn't already exist
208198 if editRepo == nil && notEditableMessage == nil {
209199 forkRepo := forkRepositoryOrError (ctx , ctx .Doer , repo_service.ForkRepoOptions {
0 commit comments