diff options
author | 6543 <6543@obermui.de> | 2021-08-31 06:16:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-31 06:16:23 +0200 |
commit | bb4cc876b1d0d5be5aa3fed7827ba3eac8f2ac18 (patch) | |
tree | 06103b4f7c74a70c8280d4b71fbebb6859ff66d3 /routers/web/repo/commit.go | |
parent | f2b4b0f491014753f509eccbcd157c198dd287b3 (diff) | |
download | gitea-bb4cc876b1d0d5be5aa3fed7827ba3eac8f2ac18.tar.gz gitea-bb4cc876b1d0d5be5aa3fed7827ba3eac8f2ac18.zip |
Repare and Improve GetDiffRangeWithWhitespaceBehavior (#16894)
* repare and improve GetDiffRangeWithWhitespaceBehavior
* Context with Timeout
Diffstat (limited to 'routers/web/repo/commit.go')
-rw-r--r-- | routers/web/repo/commit.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 6fbf11a1a0..810581640c 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -259,9 +259,8 @@ func Diff(ctx *context.Context) { repoName := ctx.Repo.Repository.Name commitID := ctx.Params(":sha") var ( - gitRepo *git.Repository - err error - repoPath string + gitRepo *git.Repository + err error ) if ctx.Data["PageIsWiki"] != nil { @@ -270,10 +269,9 @@ func Diff(ctx *context.Context) { ctx.ServerError("Repo.GitRepo.GetCommit", err) return } - repoPath = ctx.Repo.Repository.WikiPath() + defer gitRepo.Close() } else { gitRepo = ctx.Repo.GitRepo - repoPath = models.RepoPath(userName, repoName) } commit, err := gitRepo.GetCommit(commitID) @@ -297,7 +295,7 @@ func Diff(ctx *context.Context) { ctx.Data["CommitStatus"] = models.CalcCommitStatus(statuses) ctx.Data["CommitStatuses"] = statuses - diff, err := gitdiff.GetDiffCommitWithWhitespaceBehavior(repoPath, + diff, err := gitdiff.GetDiffCommitWithWhitespaceBehavior(gitRepo, commitID, setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles, gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string))) |