From 9e6e1dc950f06bbd000d5b6438f39113e8902082 Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 8 Dec 2021 19:08:16 +0000 Subject: Improve checkBranchName (#17901) The current implementation of checkBranchName is highly inefficient involving opening the repository, the listing all of the branch names checking them individually before then using using opened repo to get the tags. This PR avoids this by simply walking the references from show-ref instead of opening the repository (in the nogogit case). Signed-off-by: Andrew Thornton --- routers/web/repo/compare.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'routers/web/repo/compare.go') diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 54d7e77f2d..4cd817a399 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -660,7 +660,7 @@ func getBranchesAndTagsForRepo(repo *models.Repository) (branches, tags []string } defer gitRepo.Close() - branches, _, err = gitRepo.GetBranches(0, 0) + branches, _, err = gitRepo.GetBranchNames(0, 0) if err != nil { return nil, nil, err } @@ -711,7 +711,7 @@ func CompareDiff(ctx *context.Context) { return } - headBranches, _, err := ci.HeadGitRepo.GetBranches(0, 0) + headBranches, _, err := ci.HeadGitRepo.GetBranchNames(0, 0) if err != nil { ctx.ServerError("GetBranches", err) return -- cgit v1.2.3