summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c1e01b0)
raw | patch | inline | side by side (parent: c1e01b0)
author | Junio C Hamano <gitster@pobox.com> | |
Sat, 7 Nov 2009 07:06:06 +0000 (23:06 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 7 Nov 2009 07:17:26 +0000 (23:17 -0800) |
"commit -s" used to add an empty line before adding S-o-b line only when
the last line of the existing log message is not another S-o-b line, but
c1e01b0 (commit: More generous accepting of RFC-2822 footer lines.,
2009-10-28) introduced logic to omit this empty line when the message ends
with a run of "footer" lines, to cover S-o-b's friends, e.g. Acked-by.
However, the logic was overzealous and missed one corner case. A message
that consists of a single line that begins with Token + colon, it can be
mistaken as a S-o-b's friend. We do want an empty line in such a case.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
the last line of the existing log message is not another S-o-b line, but
c1e01b0 (commit: More generous accepting of RFC-2822 footer lines.,
2009-10-28) introduced logic to omit this empty line when the message ends
with a run of "footer" lines, to cover S-o-b's friends, e.g. Acked-by.
However, the logic was overzealous and missed one corner case. A message
that consists of a single line that begins with Token + colon, it can be
mistaken as a S-o-b's friend. We do want an empty line in such a case.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c | patch | blob | history | |
t/t7502-commit.sh | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index c395cbf14f7e99880f39a63939dc174ba494004c..cfa6b06e92924484376d853eef7171d163fe7fe1 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--)
; /* do nothing */
if (prefixcmp(sb.buf + i, sob.buf)) {
- if (!ends_rfc2822_footer(&sb))
+ if (!i || !ends_rfc2822_footer(&sb))
strbuf_addch(&sb, '\n');
strbuf_addbuf(&sb, &sob);
}
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 56cd866019dcc871e5dea684f1d879fcf2c1b884..fe94552296bb98ef78dbc51e8b1f7d4a665cf0a4 100755 (executable)
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
'
+test_expect_success 'A single-liner subject with a token plus colon is not a footer' '
+
+ git reset --hard &&
+ git commit -s -m "hello: kitty" --allow-empty &&
+ git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
+ test $(wc -l <actual) = 3
+
+'
+
test_done