Skip to content

Commit a970e84

Browse files
spearceJunio C Hamano
authored andcommitted
Allow merging bare trees in merge-recursive.
To support wider use cases, such as from within `git am -3`, the merge-recursive utility needs to accept not just commit-ish but also tree-ish as arguments on its command line. If given a tree-ish then merge-recursive will create a virtual commit wrapping it, with the subject of the commit set to the best name we can derive for that tree, which is either the command line string (probably the SHA1), or whatever string appears in GITHEAD_*. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 7ba3c07 commit a970e84

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

merge-recursive.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,9 @@ static struct commit *get_ref(const char *ref)
12681268
if (get_sha1(ref, sha1))
12691269
die("Could not resolve ref '%s'", ref);
12701270
object = deref_tag(parse_object(sha1), ref, strlen(ref));
1271+
if (object->type == OBJ_TREE)
1272+
return make_virtual_commit((struct tree*)object,
1273+
better_branch_name(ref));
12711274
if (object->type != OBJ_COMMIT)
12721275
return NULL;
12731276
if (parse_commit((struct commit *)object))

0 commit comments

Comments
 (0)