From 89932462a587e15051040aa49d99201853726dcf Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Thu, 7 Dec 2017 10:44:22 +0100 Subject: format: diff, remove error when two files are empty, submodules are simply ignored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Máximo Cuadros --- plumbing/format/diff/unified_encoder.go | 5 +---- plumbing/format/diff/unified_encoder_test.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'plumbing/format/diff') diff --git a/plumbing/format/diff/unified_encoder.go b/plumbing/format/diff/unified_encoder.go index a4ff7ab..cf2a34b 100644 --- a/plumbing/format/diff/unified_encoder.go +++ b/plumbing/format/diff/unified_encoder.go @@ -2,7 +2,6 @@ package diff import ( "bytes" - "errors" "fmt" "io" "strings" @@ -45,8 +44,6 @@ const ( DefaultContextLines = 3 ) -var ErrBothFilesEmpty = errors.New("both files are empty") - // UnifiedEncoder encodes an unified diff into the provided Writer. // There are some unsupported features: // - Similarity index for renames @@ -106,7 +103,7 @@ func (e *UnifiedEncoder) printMessage(message string) { func (e *UnifiedEncoder) header(from, to File, isBinary bool) error { switch { case from == nil && to == nil: - return ErrBothFilesEmpty + return nil case from != nil && to != nil: hashEquals := from.Hash() == to.Hash() diff --git a/plumbing/format/diff/unified_encoder_test.go b/plumbing/format/diff/unified_encoder_test.go index b832920..6e12070 100644 --- a/plumbing/format/diff/unified_encoder_test.go +++ b/plumbing/format/diff/unified_encoder_test.go @@ -20,7 +20,7 @@ func (s *UnifiedEncoderTestSuite) TestBothFilesEmpty(c *C) { buffer := bytes.NewBuffer(nil) e := NewUnifiedEncoder(buffer, 1) err := e.Encode(testPatch{filePatches: []testFilePatch{{}}}) - c.Assert(err, Equals, ErrBothFilesEmpty) + c.Assert(err, IsNil) } func (s *UnifiedEncoderTestSuite) TestBinaryFile(c *C) { -- cgit