From 1d0ce0bb57d46b02e79faa92047d8f461dc2dc0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lauris=20Buk=C5=A1is-Haberkorns?= <lauris@nix.lv>
Date: Wed, 22 Jan 2020 01:00:48 +0200
Subject: [PATCH] Check if diff actually contains sections when rendering

---
 services/gitdiff/gitdiff.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go
index b8efa8a43f6d2..fc55c035957a0 100644
--- a/services/gitdiff/gitdiff.go
+++ b/services/gitdiff/gitdiff.go
@@ -344,7 +344,7 @@ func (diffFile *DiffFile) GetHighlightClass() string {
 
 // GetTailSection creates a fake DiffLineSection if the last section is not the end of the file
 func (diffFile *DiffFile) GetTailSection(gitRepo *git.Repository, leftCommitID, rightCommitID string) *DiffSection {
-	if diffFile.Type != DiffFileChange || diffFile.IsBin || diffFile.IsLFSFile {
+	if len(diffFile.Sections) == 0 || diffFile.Type != DiffFileChange || diffFile.IsBin || diffFile.IsLFSFile {
 		return nil
 	}
 	leftCommit, err := gitRepo.GetCommit(leftCommitID)