summaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-04-26 01:39:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-04-29 20:26:03 (GMT)
commit770380156dd06cd03d83957d55484f4a98ad284f (patch)
tree6d0dcb00db9ec2cab9e62a2d7fea1c5d445de651 /builtin/merge.c
parent1cf32f4d54d7db0da9b2fb35cdd277f9ab7ae0af (diff)
downloadgit-770380156dd06cd03d83957d55484f4a98ad284f.zip
git-770380156dd06cd03d83957d55484f4a98ad284f.tar.gz
git-770380156dd06cd03d83957d55484f4a98ad284f.tar.bz2
merge: decide if we auto-generate the message early in collect_parents()
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 9f98538..eb3be68 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1098,6 +1098,10 @@ static struct commit_list *collect_parents(struct commit *head_commit,
int i;
struct commit_list *remoteheads = NULL;
struct commit_list **remotes = &remoteheads;
+ struct strbuf merge_names = STRBUF_INIT, *autogen = NULL;
+
+ if (merge_msg && (!have_message || shortlog_len))
+ autogen = &merge_names;
if (head_commit)
remotes = &commit_list_insert(head_commit, remotes)->next;
@@ -1111,15 +1115,13 @@ static struct commit_list *collect_parents(struct commit *head_commit,
remoteheads = reduce_parents(head_commit, head_subsumed, remoteheads);
- if (merge_msg &&
- (!have_message || shortlog_len)) {
- struct strbuf merge_names = STRBUF_INIT;
+ if (autogen) {
struct commit_list *p;
-
for (p = remoteheads; p; p = p->next)
- merge_name(merge_remote_util(p->item)->name, &merge_names);
- prepare_merge_message(&merge_names, merge_msg);
- strbuf_release(&merge_names);
+ merge_name(merge_remote_util(p->item)->name, autogen);
+
+ prepare_merge_message(autogen, merge_msg);
+ strbuf_release(autogen);
}
return remoteheads;