@matheusbsbs / matheus-bagliano / commits / 934d9a2407
Fork 0

merge-recur: if there is no common ancestor, fake empty one

This fixes the coolest merge ever. [jc: with two "Oops that's not it" fixes from Johannes and Alex, and an obvious type mismatch fix.] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Aug 9, 2006 at 18:43 UTC 934d9a24078e65111e9946ad3449c3fa9c06475e
1 file changed +12
merge-recursive.c
+12
@@ -1223,6 +1223,18 @@ int merge(struct commit *h1,
1223 output_commit_title(iter->item);
1224
1225 merged_common_ancestors = pop_commit(&ca);
1226 + if (merged_common_ancestors == NULL) {
1227 + /* if there is no common ancestor, make an empty tree */
1228 + struct tree *tree = xcalloc(1, sizeof(struct tree));
1229 + unsigned char hdr[40];
1230 + int hdrlen;
1231 +
1232 + tree->object.parsed = 1;
1233 + tree->object.type = OBJ_TREE;
1234 + write_sha1_file_prepare(NULL, 0, tree_type, tree->object.sha1,
1235 + hdr, &hdrlen);
1236 + merged_common_ancestors = make_virtual_commit(tree, "ancestor");
1237 + }
1238
1239 for (iter = ca; iter; iter = iter->next) {
1240 output_indent = call_depth + 1;