From 5c6d199dc675465f5e103ea36c0bfcb9d3ebc565 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Wed, 24 Apr 2019 15:20:51 +0200 Subject: plumbing: commit.Stats, fix panic on empty chucks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Máximo Cuadros --- plumbing/object/patch.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plumbing/object/patch.go b/plumbing/object/patch.go index 068589e..1efd0b1 100644 --- a/plumbing/object/patch.go +++ b/plumbing/object/patch.go @@ -321,6 +321,10 @@ func getFileStatsFromFilePatches(filePatches []fdiff.FilePatch) FileStats { for _, chunk := range fp.Chunks() { s := chunk.Content() + if len(s) == 0 { + continue + } + switch chunk.Type() { case fdiff.Add: cs.Addition += strings.Count(s, "\n") -- cgit