From 983aadd9c17987ebfc1047afd7cbc96a199ba682 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Tue, 24 Aug 2021 21:00:08 +0100 Subject: [PATCH] Prevent NPE on empty commit Handle completely empty commit as the first commit to a repository. Fix #16668 Signed-off-by: Andrew Thornton --- 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 803d614d611a..00a1859f7a34 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')