From 85e51b783c3a92b42275442147e7a27e17d42276 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 30 Jun 2008 22:18:57 -0700 Subject: Make "subtree" part more orthogonal to the rest of merge-recursive. This makes "subtree" more orthogonal to the rest of recursive merge, so that you can use subtree and ours/theirs features at the same time. For example, you can now say: git merge -s subtree -Xtheirs other to merge with "other" branch while shifting it up or down to match the shape of the tree of the current branch, and resolving conflicts favoring the changes "other" branch made over changes made in the current branch. It also allows the prefix used to shift the trees to be specified using the "-Xsubtree=$prefix" option. Giving an empty prefix tells the command to figure out how much to shift trees automatically as we have always done. "merge -s subtree" is the same as "merge -s recursive -Xsubtree=" (or "merge -s recursive -Xsubtree"). Based on an old patch done back in the days when git-merge was a script; Avery ported the script part to builtin-merge.c. Bugs in shift_tree() is mine. Signed-off-by: Avery Pennarun Signed-off-by: Junio C Hamano --- builtin-merge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'builtin-merge.c') diff --git a/builtin-merge.c b/builtin-merge.c index 42f19e1fd3..3aa7ea4052 100644 --- a/builtin-merge.c +++ b/builtin-merge.c @@ -578,7 +578,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, init_merge_options(&o); if (!strcmp(strategy, "subtree")) - o.recursive_variant = MERGE_RECURSIVE_SUBTREE; + o.subtree_shift = ""; for (x = 0; x < xopts_nr; x++) { if (!strcmp(xopts[x], "ours")) @@ -586,7 +586,9 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, else if (!strcmp(xopts[x], "theirs")) o.recursive_variant = MERGE_RECURSIVE_THEIRS; else if (!strcmp(xopts[x], "subtree")) - o.recursive_variant = MERGE_RECURSIVE_SUBTREE; + o.subtree_shift = ""; + else if (!prefixcmp(xopts[x], "subtree=")) + o.subtree_shift = xopts[x]+8; else die("Unknown option for merge-recursive: -X%s", xopts[x]); } -- cgit v1.2.1