summaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-04-21 19:00:27 +0100
committerGitHub <noreply@github.com>2021-04-21 19:00:27 +0100
commit1cd8d0ca0eede26b44a76a929f8aebac1be9a005 (patch)
tree08b2e99876d312f1c7b2dff3a7254eec6863ce6a /modules/git
parent2255afffad4ff8173c73b7cec8dbd66d986eaf5c (diff)
downloadgitea-1cd8d0ca0eede26b44a76a929f8aebac1be9a005.tar.gz
gitea-1cd8d0ca0eede26b44a76a929f8aebac1be9a005.zip
Fix NPE on view commit with notes (#15561)
Fix #15558 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/notes_nogogit.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/git/notes_nogogit.go b/modules/git/notes_nogogit.go
index 613efd2e0e..1379e50853 100644
--- a/modules/git/notes_nogogit.go
+++ b/modules/git/notes_nogogit.go
@@ -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
}