diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-06-30 22:18:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-17 22:46:28 -0800 |
commit | 85e51b783c3a92b42275442147e7a27e17d42276 (patch) | |
tree | e573051e14e607133f2914b5f08ac26fc74ab17d /builtin-merge-recursive.c | |
parent | 14e5d40ca4f4f118fe03cbe5302309170b46096d (diff) | |
download | git-85e51b783c3a92b42275442147e7a27e17d42276.tar.gz |
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 <apenwarr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-merge-recursive.c')
-rw-r--r-- | builtin-merge-recursive.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c index 1a160d8127..d8875d5892 100644 --- a/builtin-merge-recursive.c +++ b/builtin-merge-recursive.c @@ -25,10 +25,8 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix) struct commit *result; init_merge_options(&o); - if (argv[0]) { - if (!suffixcmp(argv[0], "-subtree")) - o.recursive_variant = MERGE_RECURSIVE_SUBTREE; - } + if (argv[0] && !suffixcmp(argv[0], "-subtree")) + o.subtree_shift = ""; if (argc < 4) usagef("%s <base>... -- <head> <remote> ...", argv[0]); @@ -44,7 +42,9 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix) else if (!strcmp(arg+2, "theirs")) o.recursive_variant = MERGE_RECURSIVE_THEIRS; else if (!strcmp(arg+2, "subtree")) - o.recursive_variant = MERGE_RECURSIVE_SUBTREE; + o.subtree_shift = ""; + else if (!prefixcmp(arg+2, "subtree=")) + o.subtree_shift = arg + 10; else die("Unknown option %s", arg); continue; |