Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2017-09-13 15:33:53 +0300
committerAhmad Sherif <me@ahmadsherif.com>2017-09-13 15:37:25 +0300
commit5af44c6130d149f1f269c9cc0b6d80b8a3d1b117 (patch)
treeb2012e7cceeb033dc2d51afbb072f65b5a23d7b1 /internal/diff
parent222f77398de776f44c224227edafe5657a9fe467 (diff)
Consume diff binary notice as a patch
Closes #558
Diffstat (limited to 'internal/diff')
-rw-r--r--internal/diff/diff.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/internal/diff/diff.go b/internal/diff/diff.go
index ef5aca2bd..e6b68b9ab 100644
--- a/internal/diff/diff.go
+++ b/internal/diff/diff.go
@@ -134,13 +134,11 @@ func (parser *Parser) Parse() bool {
if bytes.HasPrefix(line, []byte("diff --git")) {
break
- } else if bytes.HasPrefix(line, []byte("Binary")) {
- parser.consumeBinaryNotice()
} else if bytes.HasPrefix(line, []byte("@@")) {
parser.consumeChunkLine()
} else if helper.ByteSliceHasAnyPrefix(line, "---", "+++") {
parser.consumeLine(true)
- } else if helper.ByteSliceHasAnyPrefix(line, "-", "+", " ", "\\") {
+ } else if helper.ByteSliceHasAnyPrefix(line, "-", "+", " ", "\\", "Binary") {
parser.consumeChunkLine()
} else {
parser.consumeLine(false)
@@ -339,22 +337,16 @@ func (parser *Parser) consumeChunkLine() {
return
}
+ if bytes.HasPrefix(line, []byte("Binary")) {
+ parser.currentDiff.Binary = true
+ }
+
parser.currentDiff.Patch = append(parser.currentDiff.Patch, line...)
parser.currentDiff.lineCount++
parser.linesProcessed++
parser.bytesProcessed += len(line)
}
-func (parser *Parser) consumeBinaryNotice() {
- _, err := parser.patchReader.ReadBytes('\n')
- if err != nil && err != io.EOF {
- parser.err = fmt.Errorf("read binary notice: %v", err)
- return
- }
-
- parser.currentDiff.Binary = true
-}
-
func (parser *Parser) consumeLine(updateStats bool) {
line, err := parser.patchReader.ReadBytes('\n')
if err != nil && err != io.EOF {