Skip to content

Commit 1cd8d0c

Browse files
authored
Fix NPE on view commit with notes (#15561)
Fix #15558 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 2255aff commit 1cd8d0c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

modules/git/notes_nogogit.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package git
88

99
import (
1010
"io/ioutil"
11+
"strings"
1112
)
1213

1314
// GetNote retrieves the git-notes data for a given commit.
@@ -49,7 +50,13 @@ func GetNote(repo *Repository, commitID string, note *Note) error {
4950
}
5051
note.Message = d
5152

52-
lastCommits, err := GetLastCommitForPaths(notes, "", []string{path})
53+
treePath := ""
54+
if idx := strings.LastIndex(path, "/"); idx > -1 {
55+
treePath = path[:idx]
56+
path = path[idx+1:]
57+
}
58+
59+
lastCommits, err := GetLastCommitForPaths(notes, treePath, []string{path})
5360
if err != nil {
5461
return err
5562
}

0 commit comments

Comments
 (0)