X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-merge-recursive.c;h=d8875d589240e0c78a9e241a7d2bdde1d10ab800;hb=85f6b439f2d6ddc468d20f5ab34e11882f00375a;hp=710674c6b2cccec4f1e0baa477a11d78cda72833;hpb=47344eee9b980a7cf2a08d040ff3dd38c6cd82ec;p=git.git diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c index 710674c6b..d8875d589 100644 --- a/builtin-merge-recursive.c +++ b/builtin-merge-recursive.c @@ -25,19 +25,30 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix) struct commit *result; 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 (argv[0] && !suffixcmp(argv[0], "-subtree")) + o.subtree_shift = ""; if (argc < 4) usagef("%s ... -- ...", 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.subtree_shift = ""; + else if (!prefixcmp(arg+2, "subtree=")) + o.subtree_shift = arg + 10; + 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))