Distinguishing slight variation of modes of operation between the vanilla merge-recursive and merge-recursive-ours by the command name may have been an easy way to experiment, but we should bite the bullet and allow backend specific options to be given by the end user. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- > [Stalled/Needs more work] > > * jc/merge-theirs (Fri Jun 20 00:17:59 2008 -0700) 2 commits > - git-merge-recursive-{ours,theirs} > - git-merge-file --ours, --theirs > > Punting a merge by discarding your own work in conflicting parts but still > salvaging the parts that are cleanly automerged. It is likely that this > will result in nonsense mishmash, but somehow often people want this, so > here they are. The interface to the backends may need to change, though. Makefile | 3 --- builtin-merge-recursive.c | 23 +++++++++++++++-------- git-merge.sh | 11 ++++++++--- t/t6034-merge-ours-theirs.sh | 4 ++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 82d2892..b003e3e 100644 --- a/Makefile +++ b/Makefile @@ -304,8 +304,6 @@ BUILT_INS += git-format-patch$X BUILT_INS += git-fsck-objects$X BUILT_INS += git-get-tar-commit-id$X BUILT_INS += git-init$X -BUILT_INS += git-merge-recursive-ours$X -BUILT_INS += git-merge-recursive-theirs$X BUILT_INS += git-merge-subtree$X BUILT_INS += git-peek-remote$X BUILT_INS += git-repo-config$X @@ -1383,7 +1381,6 @@ check-docs:: do \ case "$$v" in \ git-merge-octopus | git-merge-ours | git-merge-recursive | \ - git-merge-recursive-ours | git-merge-recursive-theirs | \ git-merge-resolve | git-merge-stupid | git-merge-subtree | \ git-fsck-objects | git-init-db | \ git-?*--?* ) continue ;; \ diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c index a355e7a..6541e16 100644 --- a/builtin-merge-recursive.c +++ b/builtin-merge-recursive.c @@ -1407,12 +1407,6 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix) if (8 < namelen && !strcmp(argv[0] + namelen - 8, "-subtree")) merge_recursive_variants = MERGE_RECURSIVE_SUBTREE; - else if (5 < namelen && - !strcmp(argv[0] + namelen - 5, "-ours")) - merge_recursive_variants = MERGE_RECURSIVE_OURS; - else if (7 < namelen && - !strcmp(argv[0] + namelen - 7, "-theirs")) - merge_recursive_variants = MERGE_RECURSIVE_THEIRS; } git_config(merge_config, NULL); @@ -1423,8 +1417,21 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix) die("Usage: %s <base>... -- <head> <remote> ...\n", 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")) + merge_recursive_variants = MERGE_RECURSIVE_OURS; + else if (!strcmp(arg+2, "theirs")) + merge_recursive_variants = MERGE_RECURSIVE_THEIRS; + else if (!strcmp(arg+2, "subtree")) + merge_recursive_variants = MERGE_RECURSIVE_SUBTREE; + else + die("Unknown option %s", arg); + continue; + } if (bases_count < sizeof(bases)/sizeof(*bases)) bases[bases_count++] = argv[i]; } diff --git a/git-merge.sh b/git-merge.sh index 39b5cd9..d475852 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -17,6 +17,7 @@ commit perform a commit if the merge succeeds (default) ff allow fast forward (default) s,strategy= merge strategy to use m,message= message to be used for the merge commit (if any) +X= pass merge strategy specific options " SUBDIRECTORY_OK=Yes @@ -31,12 +32,12 @@ LF=' ' all_strategies='recur recursive octopus resolve stupid ours subtree' -all_strategies="$all_strategies recursive-ours recursive-theirs" default_twohead_strategies='recursive' default_octopus_strategies='octopus' no_fast_forward_strategies='subtree ours' -no_trivial_strategies='recursive recur subtree ours recursive-ours recursive-theirs' +no_trivial_strategies='recursive recur subtree ours' use_strategies= +backend_option= allow_fast_forward=t allow_trivial_merge=t @@ -187,6 +188,10 @@ parse_config () { merge_msg="$1" have_message=t ;; + -X) + shift + backend_option="$backend_option --$1" + ;; --) shift break ;; @@ -451,7 +456,7 @@ do # Remember which strategy left the state in the working tree wt_strategy=$strategy - git-merge-$strategy $common -- "$head_arg" "$@" + git-merge-$strategy $backend_option $common -- "$head_arg" "$@" exit=$? if test "$no_commit" = t && test "$exit" = 0 then diff --git a/t/t6034-merge-ours-theirs.sh b/t/t6034-merge-ours-theirs.sh index 56a9247..91f0f63 100755 --- a/t/t6034-merge-ours-theirs.sh +++ b/t/t6034-merge-ours-theirs.sh @@ -35,7 +35,7 @@ test_expect_success 'plain recursive - should conflict' ' test_expect_success 'recursive favouring theirs' ' git reset --hard master && - git merge -s recursive-theirs side && + git merge -s recursive -Xtheirs side && ! grep nine file && grep nueve file && ! grep 9 file && @@ -45,7 +45,7 @@ test_expect_success 'recursive favouring theirs' ' test_expect_success 'recursive favouring ours' ' git reset --hard master && - git merge -s recursive-ours side && + git merge -s recursive -Xours side && grep nine file && ! grep nueve file && ! grep 9 file && -- 1.5.6.1.102.g8e69d -- 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