Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 8993246

Browse files
committed
format: diff, remove error when two files are empty, submodules are simply ignored
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
1 parent 10f7663 commit 8993246

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

plumbing/format/diff/unified_encoder.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package diff
22

33
import (
44
"bytes"
5-
"errors"
65
"fmt"
76
"io"
87
"strings"
@@ -45,8 +44,6 @@ const (
4544
DefaultContextLines = 3
4645
)
4746

48-
var ErrBothFilesEmpty = errors.New("both files are empty")
49-
5047
// UnifiedEncoder encodes an unified diff into the provided Writer.
5148
// There are some unsupported features:
5249
// - Similarity index for renames
@@ -106,7 +103,7 @@ func (e *UnifiedEncoder) printMessage(message string) {
106103
func (e *UnifiedEncoder) header(from, to File, isBinary bool) error {
107104
switch {
108105
case from == nil && to == nil:
109-
return ErrBothFilesEmpty
106+
return nil
110107
case from != nil && to != nil:
111108
hashEquals := from.Hash() == to.Hash()
112109

plumbing/format/diff/unified_encoder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (s *UnifiedEncoderTestSuite) TestBothFilesEmpty(c *C) {
2020
buffer := bytes.NewBuffer(nil)
2121
e := NewUnifiedEncoder(buffer, 1)
2222
err := e.Encode(testPatch{filePatches: []testFilePatch{{}}})
23-
c.Assert(err, Equals, ErrBothFilesEmpty)
23+
c.Assert(err, IsNil)
2424
}
2525

2626
func (s *UnifiedEncoderTestSuite) TestBinaryFile(c *C) {

0 commit comments

Comments
 (0)