diff options
Diffstat (limited to 'services/gitdiff/gitdiff.go')
-rw-r--r-- | services/gitdiff/gitdiff.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 69c8f5603a..351bfef156 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -683,6 +683,15 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D // Get new file. if strings.HasPrefix(line, cmdDiffHead) { + if len(diff.Files) >= maxFiles { + diff.IsIncomplete = true + _, err := io.Copy(ioutil.Discard, reader) + if err != nil { + return nil, fmt.Errorf("Copy: %v", err) + } + break + } + var middle int // Note: In case file name is surrounded by double quotes (it happens only in git-shell). @@ -727,14 +736,6 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D IsRenamed: a != b, } diff.Files = append(diff.Files, curFile) - if len(diff.Files) >= maxFiles { - diff.IsIncomplete = true - _, err := io.Copy(ioutil.Discard, reader) - if err != nil { - return nil, fmt.Errorf("Copy: %v", err) - } - break - } curFileLinesCount = 0 leftLine = 1 rightLine = 1 |