Skip to content

Commit

Permalink
merge: decide if we auto-generate the message early in collect_parents()
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Apr 29, 2015
1 parent 1cf32f4 commit 7703801
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 7703801

Please sign in to comment.