From a13fb154ae2a58ee5f69763b7e6ba93a487dcad5 Mon Sep 17 00:00:00 2001
From: zeripath <art27@cantab.net>
Date: Sun, 6 Feb 2022 09:43:15 +0000
Subject: [PATCH] Stop logging an error when notes are not found (#18626)
 (#18635)

Backport #18626

This is an unnecessary logging event.

Fix #18616

Signed-off-by: Andrew Thornton <art27@cantab.net>
---
 modules/git/notes_gogit.go   | 3 +++
 modules/git/notes_nogogit.go | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/modules/git/notes_gogit.go b/modules/git/notes_gogit.go
index 6cb719ce92..b1e5e453e4 100644
--- a/modules/git/notes_gogit.go
+++ b/modules/git/notes_gogit.go
@@ -22,6 +22,9 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note)
 	log.Trace("Searching for git note corresponding to the commit %q in the repository %q", commitID, repo.Path)
 	notes, err := repo.GetCommit(NotesRef)
 	if err != nil {
+		if IsErrNotExist(err) {
+			return err
+		}
 		log.Error("Unable to get commit from ref %q. Error: %v", NotesRef, err)
 		return err
 	}
diff --git a/modules/git/notes_nogogit.go b/modules/git/notes_nogogit.go
index 13b4b7b36a..bbc8ee1371 100644
--- a/modules/git/notes_nogogit.go
+++ b/modules/git/notes_nogogit.go
@@ -21,6 +21,9 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note)
 	log.Trace("Searching for git note corresponding to the commit %q in the repository %q", commitID, repo.Path)
 	notes, err := repo.GetCommit(NotesRef)
 	if err != nil {
+		if IsErrNotExist(err) {
+			return err
+		}
 		log.Error("Unable to get commit from ref %q. Error: %v", NotesRef, err)
 		return err
 	}