aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-04-24 15:20:51 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2019-04-24 15:20:51 +0200
commit5c6d199dc675465f5e103ea36c0bfcb9d3ebc565 (patch)
treeadeb9c554654b499c08abc6ce4611d6f2c25f8d3
parentbbca4e0ccc8fee164e6da28edebbd76d69cdfd9b (diff)
downloadgo-git-5c6d199dc675465f5e103ea36c0bfcb9d3ebc565.tar.gz
plumbing: commit.Stats, fix panic on empty chucks
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
-rw-r--r--plumbing/object/patch.go4
1 files changed, 4 insertions, 0 deletions
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")