#1063859 git: commit msg without trailing \n breaks "git log --grep"ing for notes

Package:
git
Source:
git
Description:
fast, scalable, distributed revision control system
Submitter:
Jakub Wilk
Date:
2024-02-13 17:39:03 UTC
Severity:
normal
#1063859#3
Date:
2024-02-13 17:34:54 UTC
From:
To:
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".