merge: simplify merge_trivial() by using commit_list_append()
Build the commit_list of parents by calling commit_list_append() twice instead of allocating and linking the items by hand. This makes the code shorter and simpler. Rename the commit_list from parent to parents (plural) while at it because there are two of them. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
294b2680cd
commit
910a09a735
|
@ -843,16 +843,14 @@ static void prepare_to_commit(struct commit_list *remoteheads)
|
||||||
static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
|
static int merge_trivial(struct commit *head, struct commit_list *remoteheads)
|
||||||
{
|
{
|
||||||
unsigned char result_tree[20], result_commit[20];
|
unsigned char result_tree[20], result_commit[20];
|
||||||
struct commit_list *parent = xmalloc(sizeof(*parent));
|
struct commit_list *parents, **pptr = &parents;
|
||||||
|
|
||||||
write_tree_trivial(result_tree);
|
write_tree_trivial(result_tree);
|
||||||
printf(_("Wonderful.\n"));
|
printf(_("Wonderful.\n"));
|
||||||
parent->item = head;
|
pptr = commit_list_append(head, pptr);
|
||||||
parent->next = xmalloc(sizeof(*parent->next));
|
pptr = commit_list_append(remoteheads->item, pptr);
|
||||||
parent->next->item = remoteheads->item;
|
|
||||||
parent->next->next = NULL;
|
|
||||||
prepare_to_commit(remoteheads);
|
prepare_to_commit(remoteheads);
|
||||||
if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parent,
|
if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parents,
|
||||||
result_commit, NULL, sign_commit))
|
result_commit, NULL, sign_commit))
|
||||||
die(_("failed to write commit object"));
|
die(_("failed to write commit object"));
|
||||||
finish(head, remoteheads, result_commit, "In-index merge");
|
finish(head, remoteheads, result_commit, "In-index merge");
|
||||||
|
|
Loading…
Reference in New Issue