Subject: [BUG] git-am: all colons in the beginning of a subject are lost

From: Max Filenko <[email-masked]>
Date: Thu, 28 Feb 2019 11:02:11 +0100

Hi!

If there are colons in the beginning of a patch subject line `git-am'
will drop them.

Consider the following patch:

    $ cat 0001-four-colons-prepended.patch
    From e8213a2d10a61c9dc75521d88d656b8d5330e6bb Mon Sep 17 00:00:00 2001
    From: Max Filenko <[email-masked]>
    Date: Tue, 12 Feb 2019 12:21:21 +0100
    Subject: [PATCH] :::: four colons prepended
    
    ---
     file.txt | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/file.txt b/file.txt
    index 4dd1ef7..b5da95d 100644
    --- a/file.txt
    +++ b/file.txt
    @@ -1 +1 @@
    -This is a file.
    +This is a plain text file.
    -- 
    2.17.1

There will be no colons in the beginning of a commit message if I apply
this patch:

    $ git am 0001-four-colons-prepended.patch
    Applying: four colons prepended

The four colons already gone in the log message above. There are neither
no colons in the commit subject line:

    $ git show
    commit 6341a6a2872f850ecb376c268b1b3bae54a6a74f (HEAD -> master)
    Author: Max Filenko <[email-masked]>
    Date:   Tue Feb 12 12:21:21 2019 +0100
    
        four colons prepended
    
    diff --git a/file.txt b/file.txt
    index 4dd1ef7..b5da95d 100644
    --- a/file.txt
    +++ b/file.txt
    @@ -1 +1 @@
    -This is a file.
    +This is a plain text file.

I was able to reproduce this with git 2.17.1 on Ubuntu 18.04.2 LTS as
well as with git 2.17.2 (Apple Git-113) on macOS 10.14.3.

I was able to trace this down to <builtin/am.c>. It seems like there are
no colons already in the `state->msg' which to my understanding is being
filled by `read_commit_msg()' function. I would really appreciate a hand
on debugging it further.

I'm re-submitting this bug report because the original one [1] wasn't
really noticed. Hopefully, it's just because I've missed the proper
prefix in my email's subject line :)

[1]:
http://public-inbox.org/git/[email-masked]/

--
Best,
Max