summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/pull.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/pull.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/pull.go')
-rw-r--r--routers/web/repo/pull.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go
index d5aa480d1f..a7afc3a05c 100644
--- a/routers/web/repo/pull.go
+++ b/routers/web/repo/pull.go
@@ -633,10 +633,24 @@ func ViewPullFiles(ctx *context.Context) {
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
ctx.Data["AfterCommitID"] = endCommitID
- diff, err := gitdiff.GetDiffRangeWithWhitespaceBehavior(gitRepo,
- startCommitID, endCommitID, 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{
+ BeforeCommitID: startCommitID,
+ AfterCommitID: endCommitID,
+ SkipTo: ctx.FormString("skip-to"),
+ MaxLines: maxLines,
+ MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
+ MaxFiles: maxFiles,
+ WhitespaceBehavior: gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string)),
+ }, ctx.FormStrings("files")...)
if err != nil {
ctx.ServerError("GetDiffRangeWithWhitespaceBehavior", err)
return