From: David Brown <davidb@codeaurora.org>
To: git@vger.kernel.org
Subject: [PATCH] commit: More generous accepting of RFC-2822 footer lines.
Date: Tue, 27 Oct 2009 16:45:20 -0700 [thread overview]
Message-ID: <20091027234520.GA11433@quaoar.codeaurora.org> (raw)
From: David Brown <davidb@quicinc.com>
'git commit -s' will insert a blank line before the Signed-off-by
line at the end of the message, unless this last line is a
Signed-off-by line itself. Common use has other trailing lines
at the ends of commit text, in the style of RFC2822 headers.
Be more generous in considering lines to be part of this footer.
This may occasionally leave out the blank line for cases where
the commit text happens to start with a word ending in a colon,
but this results in less fixups than the extra blank lines with
Acked-by, or other custom footers.
Signed-off-by: David Brown <davidb@quicinc.com>
---
builtin-commit.c | 17 ++++++++++++++++-
t/t7501-commit.sh | 19 +++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 200ffda..f081e80 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -414,6 +414,21 @@ static void determine_author_info(void)
author_date = date;
}
+static int is_rfc2822_footer(const char *line)
+{
+ int ch;
+
+ while ((ch = *line++)) {
+ if (ch == ':')
+ return 1;
+ if ((33 <= ch && ch <= 57) ||
+ (59 <= ch && ch <= 126))
+ continue;
+ break;
+ }
+ return 0;
+}
+
static int prepare_to_commit(const char *index_file, const char *prefix,
struct wt_status *s)
{
@@ -489,7 +504,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
for (i = sb.len - 1; i > 0 && sb.buf[i - 1] != '\n'; i--)
; /* do nothing */
if (prefixcmp(sb.buf + i, sob.buf)) {
- if (prefixcmp(sb.buf + i, sign_off_header))
+ if (!is_rfc2822_footer(sb.buf + i))
strbuf_addch(&sb, '\n');
strbuf_addbuf(&sb, &sob);
}
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index e2ef532..05542b4 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -247,6 +247,25 @@ $existing" &&
'
+test_expect_success 'signoff gap' '
+
+ echo 3 >positive &&
+ git add positive &&
+ alt="Alt-RFC-822-Header: Value" &&
+ git commit -s -m "welcome
+
+$alt" &&
+ git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
+ (
+ echo welcome
+ echo
+ echo $alt
+ git var GIT_COMMITTER_IDENT |
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+ ) >expected &&
+ test_cmp expected actual
+'
+
test_expect_success 'multiple -m' '
>negative &&
--
1.6.5.1
next reply other threads:[~2009-10-27 23:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-27 23:45 David Brown [this message]
2009-10-28 0:05 ` [PATCH] commit: More generous accepting of RFC-2822 footer lines 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 ` [PATCH] commit: fix too generous RFC-2822 footer handling SZEDER Gábor
2009-11-04 6:11 ` 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=20091027234520.GA11433@quaoar.codeaurora.org \
--to=davidb@codeaurora.org \
--cc=git@vger.kernel.org \
/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).