Skip to content

Commit

Permalink
Fix panic in recursive cache (#16298)
Browse files Browse the repository at this point in the history
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 <art27@cantab.net>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
  • Loading branch information
3 people authored Jun 29, 2021
1 parent 653704c commit add74fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/git/last_commit_cache_nogogit.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (c *LastCommitCache) recursiveCache(ctx context.Context, commit *Commit, tr
if err := c.Put(commit.ID.String(), path.Join(treePath, entry), entryCommit.ID.String()); err != nil {
return err
}
if entryMap[entry].IsDir() {
// entryMap won't contain "" therefore skip this.
if treeEntry := entryMap[entry]; treeEntry != nil && treeEntry.IsDir() {
subTree, err := tree.SubTree(entry)
if err != nil {
return err
Expand Down

0 comments on commit add74fb

Please sign in to comment.