Skip to content

Commit 19b141f

Browse files
committed
Fix panic in recursive cache
There is a bug with last commit cache recursive cache where the last commit information that refers to the current tree itself will cause a panic due to its path ("") not being included in the expected tree entry paths. This PR fixes this by skipping the missing entry. Fix go-gitea#16290 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 579fcad commit 19b141f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

modules/git/last_commit_cache_nogogit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ func (c *LastCommitCache) recursiveCache(ctx context.Context, commit *Commit, tr
9494
if err := c.Put(commit.ID.String(), path.Join(treePath, entry), entryCommit.ID.String()); err != nil {
9595
return err
9696
}
97-
if entryMap[entry].IsDir() {
97+
// entryMap won't contain "" therefore skip this.
98+
if treeEntry := entryMap[entry]; treeEntry != nil && treeEntry.IsDir() {
9899
subTree, err := tree.SubTree(entry)
99100
if err != nil {
100101
return err

0 commit comments

Comments
 (0)