Fix NPE on view commit with notes #15561

Merged
lunny merged 2 commits from fix-15558-notes-path into master 2021-04-21 18:00:27 +00:00

@ -8,6 +8,7 @@ package git
import (
"io/ioutil"
"strings"
)
// GetNote retrieves the git-notes data for a given commit.
@ -49,7 +50,13 @@ func GetNote(repo *Repository, commitID string, note *Note) error {
}
note.Message = d
lastCommits, err := GetLastCommitForPaths(notes, "", []string{path})
treePath := ""
if idx := strings.LastIndex(path, "/"); idx > -1 {
treePath = path[:idx]
path = path[idx+1:]
}
lastCommits, err := GetLastCommitForPaths(notes, treePath, []string{path})
if err != nil {
return err
}