diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2006-08-09 18:43:03 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-08-09 14:54:00 -0700 |
commit | 934d9a24078e65111e9946ad3449c3fa9c06475e (patch) | |
tree | 2d3c0a364e51a392785bde9508efcede26543828 /merge-recursive.c | |
parent | c1964a006f9035cbdc6de8e55768fc6ad00d4825 (diff) | |
download | git-934d9a24078e65111e9946ad3449c3fa9c06475e.tar.gz git-934d9a24078e65111e9946ad3449c3fa9c06475e.tar.xz |
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>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r-- | merge-recursive.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/merge-recursive.c b/merge-recursive.c index 7a93dd920..d4de1adfe 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -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; |