From: Jonathan Tan <jonathantanmy@google.com>
To: git@vger.kernel.org
Cc: Jonathan Tan <jonathantanmy@google.com>
Subject: [RFC/PATCH 1/2] sequencer: refactor message and origin appending
Date: Thu, 29 Sep 2016 12:21:37 -0700 [thread overview]
Message-ID: <44fe5d92cdcd1b952fe44c9e0b37a1dbf55b38b8.1475176070.git.jonathantanmy@google.com> (raw)
In-Reply-To: <cover.1475176070.git.jonathantanmy@google.com>
In-Reply-To: <cover.1475176070.git.jonathantanmy@google.com>
Move the appending of the commit message and origin information into its
own function, in preparation for a subsequent patch.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
sequencer.c | 46 ++++++++++++++++++++++++++++------------------
1 file changed, 28 insertions(+), 18 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 3804fa9..b29c9ca 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -443,6 +443,33 @@ static int allow_empty(struct replay_opts *opts, struct commit *commit)
return 1;
}
+/*
+ * Appends the commit log message, including the cherry picked notification if
+ * record_origin is nonzero.
+ */
+static void append_message(struct strbuf *msgbuf,
+ const struct commit_message *msg,
+ int record_origin,
+ const struct commit *commit)
+{
+ /*
+ * Append the commit log message to msgbuf; it starts
+ * after the tree, parent, author, committer
+ * information followed by "\n\n".
+ */
+ const char *p = strstr(msg->message, "\n\n");
+ if (p)
+ strbuf_addstr(msgbuf, skip_blank_lines(p + 2));
+
+ if (record_origin) {
+ if (!has_conforming_footer(msgbuf, NULL, 0))
+ strbuf_addch(msgbuf, '\n');
+ strbuf_addstr(msgbuf, cherry_picked_prefix);
+ strbuf_addstr(msgbuf, oid_to_hex(&commit->object.oid));
+ strbuf_addstr(msgbuf, ")\n");
+ }
+}
+
static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
{
unsigned char head[20];
@@ -534,29 +561,12 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
}
strbuf_addstr(&msgbuf, ".\n");
} else {
- const char *p;
-
base = parent;
base_label = msg.parent_label;
next = commit;
next_label = msg.label;
- /*
- * Append the commit log message to msgbuf; it starts
- * after the tree, parent, author, committer
- * information followed by "\n\n".
- */
- p = strstr(msg.message, "\n\n");
- if (p)
- strbuf_addstr(&msgbuf, skip_blank_lines(p + 2));
-
- if (opts->record_origin) {
- if (!has_conforming_footer(&msgbuf, NULL, 0))
- strbuf_addch(&msgbuf, '\n');
- strbuf_addstr(&msgbuf, cherry_picked_prefix);
- strbuf_addstr(&msgbuf, oid_to_hex(&commit->object.oid));
- strbuf_addstr(&msgbuf, ")\n");
- }
+ append_message(&msgbuf, &msg, opts->record_origin, commit);
}
if (!opts->strategy || !strcmp(opts->strategy, "recursive") || opts->action == REPLAY_REVERT) {
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-09-29 19:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-29 19:21 [RFC/PATCH 0/2] place cherry pick line below commit title Jonathan Tan
2016-09-29 19:21 ` Jonathan Tan [this message]
2016-09-29 19:21 ` [RFC/PATCH 2/2] sequencer: allow origin " Jonathan Tan
2016-09-29 21:56 ` [RFC/PATCH 0/2] place cherry pick " Junio C Hamano
2016-09-30 18:22 ` Jonathan Tan
2016-09-30 19:34 ` Junio C Hamano
2016-09-30 20:23 ` Jonathan Tan
2016-10-03 15:23 ` Junio C Hamano
2016-09-30 20:49 ` Junio C Hamano
2016-10-03 17:44 ` Jonathan Tan
2016-10-03 19:17 ` Junio C Hamano
2016-10-03 21:28 ` Jonathan Tan
2016-10-03 22:13 ` Junio C Hamano
2016-10-04 0:08 ` Jonathan Tan
2016-10-04 17:25 ` Junio C Hamano
2016-10-04 18:28 ` Junio C Hamano
2016-10-05 19:44 ` Jonathan Tan
2016-10-06 19:24 ` Junio C Hamano
2016-10-05 19:38 ` Jonathan Tan
2016-10-05 20:33 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44fe5d92cdcd1b952fe44c9e0b37a1dbf55b38b8.1475176070.git.jonathantanmy@google.com \
--to=jonathantanmy@google.com \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).