[PATCH 9/11] Allow merging bare trees in merge-recursive.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 merge-recursive.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 1c84ed7..bac16f5 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1268,6 +1268,9 @@ static struct commit *get_ref(const char *ref)
 	if (get_sha1(ref, sha1))
 		die("Could not resolve ref '%s'", ref);
 	object = deref_tag(parse_object(sha1), ref, strlen(ref));
+	if (object->type == OBJ_TREE)
+		return make_virtual_commit((struct tree*)object,
+			better_branch_name(ref));
 	if (object->type != OBJ_COMMIT)
 		return NULL;
 	if (parse_commit((struct commit *)object))
-- 
1.4.4.3.gd2e4

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]