From 2148b27bfa8c21714cf5d871a3e04e22606d138f Mon Sep 17 00:00:00 2001
From: zeripath <art27@cantab.net>
Date: Wed, 25 Aug 2021 13:22:48 +0100
Subject: [PATCH] Prevent NPE on empty commit (#16812) (#16819)

Backport #16812

Handle completely empty commit as the first commit to a repository.

Fix #16668

Signed-off-by: Andrew Thornton art27@cantab.net
---
 modules/git/log_name_status.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/modules/git/log_name_status.go b/modules/git/log_name_status.go
index 803d614d61..00a1859f7a 100644
--- a/modules/git/log_name_status.go
+++ b/modules/git/log_name_status.go
@@ -167,6 +167,9 @@ func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int
 				return nil, err
 			}
 		}
+		if len(g.next) == 0 {
+			return &ret, nil
+		}
 		if g.next[0] == '\x00' {
 			g.buffull = false
 			g.next, err = g.rd.ReadSlice('\x00')