From: Jonathan Nieder <jrnieder@gmail.com>
To: Oswald Buddenhagen <ossi@kde.org>
Cc: git@vger.kernel.org, Michael J Gruber <git@drmicha.warpmail.net>,
Martin Svensson <martin.k.svensson@netinsight.se>,
Jay Soffian <jaysoffian@gmail.com>, Jeff King <peff@peff.net>
Subject: Re: [PATCH] cherry-pick -x: add newline before pick note
Date: Tue, 8 Mar 2011 16:08:43 -0600 [thread overview]
Message-ID: <20110308220843.GA27156@elie> (raw)
In-Reply-To: <loom.20110308T134920-72@post.gmane.org>
(please do not cull the CC list)
Hi Oswald,
Oswald Buddenhagen wrote:
> so while everybody is apparently thinking about totally over-engineering
> things as much as possible, could we please have this patch applied so we
> have a solution for the time being?
I am not convinced that this patch makes a positive change in general.
Starting from a message
Foo the bar
Make some excellent improvement to the frobnicator.
Signed-off-by: A U Thor <author@example.com>
a person passing on the patch might write
Foo the bar
[...]
Signed-off-by: A U Thor <author@example.com>
[committer@example.com: avoid multiple return points]
Signed-off-by: C O Mitter <committer@example.com>
Similarly, when cherry-picking from permanent history, it can make
sense to write
Foo the bar
[...]
Signed-off-by: A U Thor <author@example.com>
(cherry picked from commit 78a8b989a76c8798a9898c98a98c98a98ca)
Signed-off-by: C O Mitter <committer@example.com>
In both cases, it's just another hop in the life of a patch and not
something that seems to deserve emphasis with extra whitespace.
> i really hate to tell my coworkers that
> they have to amend the cherry-picks just to make them comply with git's
> own guidelines for well-formed commit messages (and thus have them pass
> our pre-receive hook).
I assume you are referring to one-line commit messages becoming two-line?
Here's something rough to start.
diff --git a/builtin/revert.c b/builtin/revert.c
index dc1b702..343e7e7 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -198,6 +198,28 @@ static void add_message_to_msg(struct strbuf *msgbuf, const char *message)
strbuf_addstr(msgbuf, p);
}
+static void add_blank_line_if_oneline(struct strbuf *msgbuf)
+{
+ const char *newline = memchr(msgbuf->buf, '\n', msgbuf->len);
+
+ if (!newline) { /* No newline at end of message. */
+ strbuf_addch(msgbuf, '\n');
+ newline = msgbuf->buf + msgbuf->len - 1;
+ }
+
+ /*
+ * If the change description consists of a single line,
+ * add a blank line separating the title from the new
+ * message body (the "(cherry picked from" line).
+ *
+ * NEEDSWORK: it would be better to reuse the append_signoff
+ * logic.
+ */
+ newline = memchr(newline, '\n', msgbuf-> buf + msgbuf->len - newline);
+ if (!newline)
+ strbuf_addch(msgbuf, '\n');
+}
+
static void set_author_ident_env(const char *message)
{
const char *p = message;
@@ -499,6 +521,7 @@ static int do_pick_commit(void)
next_label = msg.label;
set_author_ident_env(msg.message);
add_message_to_msg(&msgbuf, msg.message);
+ add_blank_line_if_oneline(&msgbuf);
if (no_replay) {
strbuf_addstr(&msgbuf, "(cherry picked from commit ");
strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1));
--
next prev parent reply other threads:[~2011-03-08 22:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 15:11 [PATCH] cherry-pick -x: add newline before pick note Michael J Gruber
2010-11-16 19:30 ` Jeff King
2010-11-16 20:25 ` [PATCH] commit -s: allow "(cherry picked " lines in sign-off section Jonathan Nieder
2010-11-16 20:40 ` Jonathan Nieder
2010-11-16 22:52 ` Junio C Hamano
2010-11-16 23:36 ` Jonathan Nieder
2010-11-17 16:46 ` Junio C Hamano
2010-11-17 6:23 ` Jay Soffian
2010-11-17 6:14 ` [PATCH] cherry-pick -x: add newline before pick note Jay Soffian
2011-03-08 12:54 ` Oswald Buddenhagen
2011-03-08 22:08 ` Jonathan Nieder [this message]
2011-03-08 22:18 ` Oswald Buddenhagen
2011-03-08 22:34 ` Jonathan Nieder
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=20110308220843.GA27156@elie \
--to=jrnieder@gmail.com \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=jaysoffian@gmail.com \
--cc=martin.k.svensson@netinsight.se \
--cc=ossi@kde.org \
--cc=peff@peff.net \
/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).