]> source.dussan.org Git - gitea.git/commitdiff
Check if diff actually contains sections when rendering (#9926)
authorLauris BH <lauris@nix.lv>
Wed, 22 Jan 2020 07:20:58 +0000 (09:20 +0200)
committerGitHub <noreply@github.com>
Wed, 22 Jan 2020 07:20:58 +0000 (09:20 +0200)
services/gitdiff/gitdiff.go

index b8efa8a43f6d269d7820af270169ef6bcbfe2bb4..fc55c035957a03536538373f81178e89e8ba270e 100644 (file)
@@ -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)