Skip to content

Commit add74fb

Browse files
zeripath6543techknowlogick
authored
Fix panic in recursive cache (#16298)
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 #16290 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 653704c commit add74fb

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)