summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/commit.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-11-21 16:51:08 +0000
committerGitHub <noreply@github.com>2021-11-22 00:51:08 +0800
commit8511eec4d447499e37c1c3fbe3b1f9353ce36190 (patch)
tree2320539c50d2813906d0635b9dbe4b2ba19aadd8 /routers/web/repo/commit.go
parentd710af6669654f27f02b69d7ef1ba563e7d58a90 (diff)
downloadgitea-8511eec4d447499e37c1c3fbe3b1f9353ce36190.tar.gz
gitea-8511eec4d447499e37c1c3fbe3b1f9353ce36190.zip
Allow Loading of Diffs that are too large (#17739)
* Allow Loading of Diffs that are too large This PR allows the loading of diffs that are suppressed because the file is too large. It does not handle diffs of files which have lines which are too long. Fix #17738 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers/web/repo/commit.go')
-rw-r--r--routers/web/repo/commit.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index c9e2b94f23..ecb5107a3d 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -262,8 +262,6 @@ func Diff(ctx *context.Context) {
err error
)
- fileOnly := ctx.FormBool("file-only")
-
if ctx.Data["PageIsWiki"] != nil {
gitRepo, err = git.OpenRepository(ctx.Repo.Repository.WikiPath())
if err != nil {
@@ -288,13 +286,23 @@ func Diff(ctx *context.Context) {
commitID = commit.ID.String()
}
- diff, err := gitdiff.GetDiffCommitWithWhitespaceBehavior(gitRepo,
- commitID, ctx.FormString("skip-to"), setting.Git.MaxGitDiffLines,
- setting.Git.MaxGitDiffLineCharacters, setting.Git.MaxGitDiffFiles,
- gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string)),
- false)
+ fileOnly := ctx.FormBool("file-only")
+ maxLines, maxFiles := setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffFiles
+ files := ctx.FormStrings("files")
+ if fileOnly && (len(files) == 2 || len(files) == 1) {
+ maxLines, maxFiles = -1, -1
+ }
+
+ diff, err := gitdiff.GetDiff(gitRepo, &gitdiff.DiffOptions{
+ AfterCommitID: commitID,
+ SkipTo: ctx.FormString("skip-to"),
+ MaxLines: maxLines,
+ MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
+ MaxFiles: maxFiles,
+ WhitespaceBehavior: gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string)),
+ }, files...)
if err != nil {
- ctx.NotFound("GetDiffCommitWithWhitespaceBehavior", err)
+ ctx.NotFound("GetDiff", err)
return
}
@@ -325,10 +333,6 @@ func Diff(ctx *context.Context) {
ctx.Data["Title"] = commit.Summary() + " ยท " + base.ShortSha(commitID)
ctx.Data["Commit"] = commit
ctx.Data["Diff"] = diff
- if fileOnly {
- ctx.HTML(http.StatusOK, tplDiffBox)
- return
- }
statuses, err := models.GetLatestCommitStatus(ctx.Repo.Repository.ID, commitID, db.ListOptions{})
if err != nil {