diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-04-25 18:29:44 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-29 13:19:21 -0700 |
commit | 52fecab20cf28f4b5621e502a265ba551a26877e (patch) | |
tree | 4df960a94b182844d4f7f1d58577cbaa271b033f | |
parent | merge: narrow scope of merge_names (diff) | |
download | tgif-52fecab20cf28f4b5621e502a265ba551a26877e.tar.xz |
merge: extract prepare_merge_message() logic out
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/merge.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index d853c9d805..a972ed6422 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1076,6 +1076,20 @@ static struct commit_list *reduce_parents(struct commit *head_commit, return remoteheads; } +static void prepare_merge_message(struct strbuf *merge_names, struct strbuf *merge_msg) +{ + struct fmt_merge_msg_opts opts; + + memset(&opts, 0, sizeof(opts)); + opts.add_title = !have_message; + opts.shortlog_len = shortlog_len; + opts.credit_people = (0 < option_edit); + + fmt_merge_msg(merge_names, merge_msg, &opts); + if (merge_msg->len) + strbuf_setlen(merge_msg, merge_msg->len - 1); +} + static struct commit_list *collect_parents(struct commit *head_commit, int *head_subsumed, int argc, const char **argv) @@ -1248,20 +1262,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (!have_message || shortlog_len) { struct strbuf merge_names = STRBUF_INIT; - struct fmt_merge_msg_opts opts; for (p = remoteheads; p; p = p->next) merge_name(merge_remote_util(p->item)->name, &merge_names); - - memset(&opts, 0, sizeof(opts)); - opts.add_title = !have_message; - opts.shortlog_len = shortlog_len; - opts.credit_people = (0 < option_edit); - - fmt_merge_msg(&merge_names, &merge_msg, &opts); - if (merge_msg.len) - strbuf_setlen(&merge_msg, merge_msg.len - 1); - + prepare_merge_message(&merge_names, &merge_msg); strbuf_release(&merge_names); } } |