Skip to content

Commit

Permalink
merge-recur: if there is no common ancestor, fake empty one
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Aug 9, 2006
1 parent c1964a0 commit 934d9a2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,18 @@ int merge(struct commit *h1,
output_commit_title(iter->item);

merged_common_ancestors = pop_commit(&ca);
if (merged_common_ancestors == NULL) {
/* if there is no common ancestor, make an empty tree */
struct tree *tree = xcalloc(1, sizeof(struct tree));
unsigned char hdr[40];
int hdrlen;

tree->object.parsed = 1;
tree->object.type = OBJ_TREE;
write_sha1_file_prepare(NULL, 0, tree_type, tree->object.sha1,
hdr, &hdrlen);
merged_common_ancestors = make_virtual_commit(tree, "ancestor");
}

for (iter = ca; iter; iter = iter->next) {
output_indent = call_depth + 1;
Expand Down

0 comments on commit 934d9a2

Please sign in to comment.