From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: David Brown <davidb@codeaurora.org>, git@vger.kernel.org
Subject: Re: [PATCH] commit: fix too generous RFC-2822 footer handling
Date: Wed, 4 Nov 2009 16:11:14 +0100 [thread overview]
Message-ID: <20091104151114.GD6118@neumann> (raw)
In-Reply-To: <7vljimlsza.fsf@alter.siamese.dyndns.org>
Hi,
On Tue, Nov 03, 2009 at 10:11:21PM -0800, Junio C Hamano wrote:
> That looks overly convoluted.
I figured that the function ends_rfc2822_footer() should tell us
whether the message, well, ends with an rfc2822 _footer_. But since
it may say so even if there is only a single line in the commit
message, I thought this function should be fixed in the first place.
But yeah, that solution was unnecessarily complicated, after a good
night's sleep I would do it this way:
diff --git a/builtin-commit.c b/builtin-commit.c
index beddf01..c7dcbd0 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -428,6 +428,8 @@ static int ends_rfc2822_footer(struct strbuf *sb)
break;
hit = (buf[i] == '\n');
}
+ if (i == 0) /* one-line message */
+ return 0;
while (i < len - 1 && buf[i] == '\n')
i++;
> Why isn't the attached patch enough?
>
> - We inspected the last line of the message buffer, and 'i' is at the
> beginning of that last line;
>
> - At the line that begins at 'i', we found something that does not match
> the sob we are going to add;
>
> - We want a newline if it is a single liner (i.e. i == 0), or if that
> last one is not sob/acked-by and friends.
You are right in that there is no need to look for an rfc-2822
formatted footer when the commit message has only a single line. But
ends_rfc2822_footer() still not completely behaves as its name would
suggest (i.e. it might match even if there is no footer). Perhaps it
could just be renamed to ends_rfc282().
Best,
Gábor
prev parent reply other threads:[~2009-11-04 15:11 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 ` [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 [this message]
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=20091104151114.GD6118@neumann \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.