summaryrefslogtreecommitdiff
path: root/builtin-merge-recursive.c
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2009-11-25 21:23:55 -0500
committerJunio C Hamano <gitster@pobox.com>2010-01-17 22:45:06 -0800
commit8cc5b29065e19267cbc08b39c34674b02c2e3d59 (patch)
treea7fc209fac5df7d2a9c9a5795fb4f58746ae3840 /builtin-merge-recursive.c
parent73eb40eeaaebc5ebae283c06286b96b4aea00143 (diff)
downloadgit-8cc5b29065e19267cbc08b39c34674b02c2e3d59.tar.gz
git merge -X<option>
Teach "-X <option>" command line argument to "git merge" that is passed to strategy implementations. "ours" and "theirs" autoresolution introduced by the previous commit can be asked to the recursive strategy. 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.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c
index 710674c6b2..1a160d8127 100644
--- a/builtin-merge-recursive.c
+++ b/builtin-merge-recursive.c
@@ -26,18 +26,29 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
init_merge_options(&o);
if (argv[0]) {
- int namelen = strlen(argv[0]);
- if (8 < namelen &&
- !strcmp(argv[0] + namelen - 8, "-subtree"))
- o.subtree_merge = 1;
+ if (!suffixcmp(argv[0], "-subtree"))
+ o.recursive_variant = MERGE_RECURSIVE_SUBTREE;
}
if (argc < 4)
usagef("%s <base>... -- <head> <remote> ...", argv[0]);
for (i = 1; i < argc; ++i) {
- if (!strcmp(argv[i], "--"))
- break;
+ const char *arg = argv[i];
+
+ if (!prefixcmp(arg, "--")) {
+ if (!arg[2])
+ break;
+ if (!strcmp(arg+2, "ours"))
+ o.recursive_variant = MERGE_RECURSIVE_OURS;
+ else if (!strcmp(arg+2, "theirs"))
+ o.recursive_variant = MERGE_RECURSIVE_THEIRS;
+ else if (!strcmp(arg+2, "subtree"))
+ o.recursive_variant = MERGE_RECURSIVE_SUBTREE;
+ else
+ die("Unknown option %s", arg);
+ continue;
+ }
if (bases_count < ARRAY_SIZE(bases)-1) {
unsigned char *sha = xmalloc(20);
if (get_sha1(argv[i], sha))