* [BUG] git-am: all colons in the beginning of a subject are lost
@ 2019-02-28 10:02 Max Filenko
2019-02-28 11:26 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: Max Filenko @ 2019-02-28 10:02 UTC (permalink / raw)
To: git
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 <contact@filenko.ms>
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 <contact@filenko.ms>
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/m2lg2lxmmm.fsf@bouncer.i-did-not-set--mail-host-address--so-tickle-me/
--
Best,
Max
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [BUG] git-am: all colons in the beginning of a subject are lost
2019-02-28 10:02 [BUG] git-am: all colons in the beginning of a subject are lost Max Filenko
@ 2019-02-28 11:26 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2019-02-28 11:26 UTC (permalink / raw)
To: Max Filenko; +Cc: git
On Thu, Feb 28, 2019 at 11:02:11AM +0100, Max Filenko wrote:
> Subject: [PATCH] :::: four colons prepended
> [...]
> 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
I suspect this has to do with the sanitization that happens as part of
removing "[PATCH]". Note that if you use "-k" (to preserve the subject)
it doesn't happen, though of course you also get "[PATCH]" then.
If you want to pass the subject lines through verbatim, use "-k" with
both format-patch and git-am.
> 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.
It's probably easier to debug with git-mailinfo, which has the same
behavior:
$ git mailinfo msg patch <0001-four-colons-prepended.patch
Author: Jeff King
Email: peff@peff.net
Subject: four colons prepended
Date: Thu, 28 Feb 2019 06:12:50 -0500
and is based on the same routines.
The contents are preserved until we end up in mailinfo.c's
cleanup_subject(). And there leading colons are explicitly removed:
case ' ': case '\t': case ':':
strbuf_remove(subject, at, 1);
continue;
That behavior goes all the way back to 2744b2344d (Start of early patch
applicator tools for git., 2005-04-11), when Git was only 4 days old.
Since it also handles cruft like "Re:", I suspect the goal there was I
suspect the goal there was to remove cruft like "Re::::" or "Re: :"
which sometimes happens. I don't know if anybody would complain if we
were more careful about leaving lone colons that weren't part of a "Re"
chain.
-Peff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-28 11:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-28 10:02 [BUG] git-am: all colons in the beginning of a subject are lost Max Filenko
2019-02-28 11:26 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).