forked from forgejo/forgejo
Repare and Improve GetDiffRangeWithWhitespaceBehavior (#16894)
* repare and improve GetDiffRangeWithWhitespaceBehavior * Context with Timeout
This commit is contained in:
parent
f2b4b0f491
commit
bb4cc876b1
5 changed files with 26 additions and 37 deletions
|
@ -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)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue