diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2017-05-30 13:57:17 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2017-06-06 13:43:26 +0300 |
commit | ad487bae3aa3eb109a44bae391f569eb2aca4ebe (patch) | |
tree | 9194d04b2496c43f6ca3ee1a17342e2167c782a4 /internal/diff | |
parent | 83b8d9226a05fddc547c0fe31ece5e9fc8abc596 (diff) |
Update CommitDiff RPC to chunk patches over messages
Diffstat (limited to 'internal/diff')
-rw-r--r-- | internal/diff/diff.go | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/internal/diff/diff.go b/internal/diff/diff.go index 8dd2e80f1..20c84df98 100644 --- a/internal/diff/diff.go +++ b/internal/diff/diff.go @@ -15,15 +15,15 @@ const blankID = "0000000000000000000000000000000000000000" // Diff represents a single parsed diff entry type Diff struct { - FromID string - ToID string - OldMode int32 - NewMode int32 - FromPath []byte - ToPath []byte - Binary bool - Status byte - RawChunks [][]byte + FromID string + ToID string + OldMode int32 + NewMode int32 + FromPath []byte + ToPath []byte + Binary bool + Status byte + Patch []byte } // Parser holds necessary state for parsing a diff stream @@ -101,8 +101,6 @@ func (parser *Parser) Parse() bool { } else if bytes.HasPrefix(line, []byte("Binary")) { parser.err = consumeBinaryNotice(parser.patchReader, parser.currentDiff) } else if bytes.HasPrefix(line, []byte("@@")) { - parser.currentDiff.RawChunks = append(parser.currentDiff.RawChunks, nil) - parser.err = consumeChunkLine(parser.patchReader, parser.currentDiff) } else if helper.ByteSliceHasAnyPrefix(line, "---", "+++") { parser.err = consumeLine(parser.patchReader) @@ -263,8 +261,7 @@ func consumeChunkLine(reader *bufio.Reader, diff *Diff) error { return fmt.Errorf("read chunk line: %v", err) } - chunkIndex := len(diff.RawChunks) - 1 - diff.RawChunks[chunkIndex] = append(diff.RawChunks[chunkIndex], line...) + diff.Patch = append(diff.Patch, line...) return nil } |