Skip to content

Commit 344e8f4

Browse files
committed
MultiFileDiffReader returns trailing content
Along with EOF. This is useful for handling mixed diff and non-diff output. Note that "stray" content between diff files was already included in the extended headers for the next diff. All this commit does is return a partial FileDiff, with only extended headers and no actual diff content, along with an EOF.
1 parent 82e3467 commit 344e8f4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cmd/go-diff/go-diff.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ func main() {
4646
label = fmt.Sprintf("orig(%s) new(%s)", fdiff.OrigName, fdiff.NewName)
4747
}
4848
if err == io.EOF {
49+
// Any trailing content is found in extended headers for the "next" diff,
50+
// that was never found.
51+
if fdiff != nil {
52+
for _, extended := range fdiff.Extended {
53+
fmt.Println(extended)
54+
}
55+
}
4956
break
5057
}
5158
if err != nil {

diff/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (r *MultiFileDiffReader) ReadFile() (*FileDiff, error) {
5959
switch e := err.(type) {
6060
case *ParseError:
6161
if e.Err == ErrNoFileHeader || e.Err == ErrExtendedHeadersEOF {
62-
return nil, io.EOF
62+
return fd, io.EOF
6363
}
6464
return nil, err
6565

0 commit comments

Comments
 (0)