From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Junio C Hamano <gitster@pobox.com>, David Brown <davidb@codeaurora.org>
Cc: git@vger.kernel.org, "SZEDER Gábor" <szeder@ira.uka.de>
Subject: [PATCH] commit: fix too generous RFC-2822 footer handling
Date: Wed, 4 Nov 2009 04:09:06 +0100 [thread overview]
Message-ID: <1257304146-15543-1-git-send-email-szeder@ira.uka.de> (raw)
In-Reply-To: <20091103165951.GA2241@neumann>
Since commit c1e01b0c (commit: More generous accepting of RFC-2822
footer lines, 2009-10-28) RFC-2822-looking lines at the end of the
message are considered part of the footer and 'git commit -s -m'
doesn't add a newline between that footer and the new S-O-B line.
This new behaviour causes problems with subject-only commit messages
which happens to look like an RFC-2822 header (e.g. 'git commit -s -m
"subsystem: coolest feature ever"'). In such cases there won't be any
newline between the subject and the S-O-B line, and the S-O-B line
will show up at places where it should not (e.g. in the output of 'git
shortlog').
With this patch the newline will be always added if a commit message
has only a single line, even if it looks like an RFC-2822 header.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
Maybe something like this? Be careful when reviewing, it's 4AM
here...
builtin-commit.c | 8 ++++++++
t/t7501-commit.sh | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index beddf01..4971156 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -429,6 +429,14 @@ static int ends_rfc2822_footer(struct strbuf *sb)
hit = (buf[i] == '\n');
}
+ for (j = i-1; j > 0; j--)
+ if (buf[j] == '\n') {
+ hit = 1;
+ break;
+ }
+ if (!hit) /* one-line message */
+ return 0;
+
while (i < len - 1 && buf[i] == '\n')
i++;
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index d2de576..aaeedda 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -215,10 +215,10 @@ test_expect_success 'sign off (1)' '
echo 1 >positive &&
git add positive &&
- git commit -s -m "thank you" &&
+ git commit -s -m "subsystem: coolest feature ever" &&
git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
(
- echo thank you
+ echo subsystem: coolest feature ever
echo
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
--
1.6.5.2.201.g0f47
next prev parent reply other threads:[~2009-11-04 3:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-27 23:45 [PATCH] commit: More generous accepting of RFC-2822 footer lines David Brown
2009-10-28 0:05 ` Shawn O. Pearce
2009-10-28 7:14 ` Junio C Hamano
2009-10-28 14:23 ` David Brown
2009-10-28 17:13 ` David Brown
2009-10-28 18:06 ` Junio C Hamano
2009-10-28 18:17 ` David Brown
2009-11-03 16:59 ` SZEDER Gábor
2009-11-04 3:09 ` SZEDER Gábor [this message]
2009-11-04 6:11 ` [PATCH] commit: fix too generous RFC-2822 footer handling Junio C Hamano
2009-11-04 15:11 ` SZEDER Gábor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1257304146-15543-1-git-send-email-szeder@ira.uka.de \
--to=szeder@ira.uka.de \
--cc=davidb@codeaurora.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).