Let's create a commit with a message that doesn't end with newline¹, and
attach a note to it:
$ commit=$(printf 'foo' | git commit-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904)
$ git notes add -m bar $commit
$ git log $commit --grep bar
commit e0e2391bad1644f1dd580c0d5d6c5b58addf2870
Author: Jakub Wilk <jwilk@jwilk.net>
Date: 2024-02-13 18:00:51 +0100
foo
Notes:
bar
So far so good, but if you anchor the regex, the commit can no longer be
found:
$ git log $commit --grep ^bar
[nothing]
Apparently that's because git concatenates the commit message and the
note without inserting newline between them:
$ git log $commit --grep ^foobar
commit e0e2391bad1644f1dd580c0d5d6c5b58addf2870
Author: Jakub Wilk <jwilk@jwilk.net>
Date: 2024-02-13 18:00:51 +0100
foo
Notes:
bar
¹ See also bug #1063857 "github-backup: commit messages don't end with
newline".