summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-10-17 17:25:45 -0400
committerUnknwon <u@gogs.io>2015-10-17 17:25:45 -0400
commit6599869f2881a7ae690a68e5a08e2c2a0703aaf2 (patch)
tree31d09ca8ed22eed0af59023d0af6aff23efde47f
parent932dbccb6738b2894e4faafce4f834ef6803efc6 (diff)
downloadgitea-6599869f2881a7ae690a68e5a08e2c2a0703aaf2.tar.gz
gitea-6599869f2881a7ae690a68e5a08e2c2a0703aaf2.zip
#1790 fast return for too large diff
-rw-r--r--gogs.go2
-rw-r--r--models/git_diff.go14
-rw-r--r--templates/.VERSION2
3 files changed, 5 insertions, 13 deletions
diff --git a/gogs.go b/gogs.go
index f1e83532f0..a7d44a2aa6 100644
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.6.16.1015 Beta"
+const APP_VER = "0.6.16.1017 Beta"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
diff --git a/models/git_diff.go b/models/git_diff.go
index 6698565001..2335e46808 100644
--- a/models/git_diff.go
+++ b/models/git_diff.go
@@ -86,7 +86,6 @@ func ParsePatch(pid int64, maxlines int, cmd *exec.Cmd, reader io.Reader) (*Diff
}
leftLine, rightLine int
- isTooLong bool
// FIXME: Should use cache in the future.
buf bytes.Buffer
)
@@ -107,9 +106,10 @@ func ParsePatch(pid int64, maxlines int, cmd *exec.Cmd, reader io.Reader) (*Diff
i = i + 1
// Diff data too large, we only show the first about maxlines lines
- if i == maxlines {
- isTooLong = true
+ if i >= maxlines {
log.Warn("Diff data too large")
+ diff.Files = nil
+ return diff, nil
}
switch {
@@ -120,10 +120,6 @@ func ParsePatch(pid int64, maxlines int, cmd *exec.Cmd, reader io.Reader) (*Diff
curSection.Lines = append(curSection.Lines, diffLine)
continue
case line[0] == '@':
- if isTooLong {
- break
- }
-
curSection = &DiffSection{}
curFile.Sections = append(curFile.Sections, curSection)
ss := strings.Split(line, "@@")
@@ -162,10 +158,6 @@ func ParsePatch(pid int64, maxlines int, cmd *exec.Cmd, reader io.Reader) (*Diff
// Get new file.
if strings.HasPrefix(line, DIFF_HEAD) {
- if isTooLong {
- break
- }
-
beg := len(DIFF_HEAD)
a := line[beg : (len(line)-beg)/2+beg]
diff --git a/templates/.VERSION b/templates/.VERSION
index 581883e0ca..ddb56b4d0b 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.6.16.1015 Beta \ No newline at end of file
+0.6.16.1017 Beta \ No newline at end of file