• Bug#1063859: git: commit msg without trailing \n breaks "git log --grep

    From Jakub Wilk@21:1/5 to All on Tue Feb 13 18:40:02 2024
    Package: git
    Version: 1:2.39.2-1.1

    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".


    -- System Information:
    Architecture: i386

    Versions of packages git depends on:
    ii libc6 2.36-9+deb12u4
    ii libcurl3-gnutls 7.88.1-10+deb12u5
    ii libexpat1 2.5.0-1
    ii libpcre2-8-0 10.42-1
    ii zlib1g 1:1.2.13.dfsg-1
    ii perl 5.36.0-7+deb12u1
    ii liberror-perl 0.17029-2
    ii git-man 1:2.39.2-1.1

    --
    Jakub Wilk

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)