]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/merge.c
Merge branch 'so/log-diff-merge'
[thirdparty/git.git] / builtin / merge.c
index 1f7b69982b409b14e7c8322693a4f255dd820db2..eb00b273e668e2725447a2d6a0edc5ad2d67ed67 100644 (file)
@@ -29,6 +29,7 @@
 #include "rerere.h"
 #include "help.h"
 #include "merge-recursive.h"
+#include "merge-ort-wrappers.h"
 #include "resolve-undo.h"
 #include "remote.h"
 #include "fmt-merge-msg.h"
@@ -89,6 +90,7 @@ static int no_verify;
 static struct strategy all_strategy[] = {
        { "recursive",  DEFAULT_TWOHEAD | NO_TRIVIAL },
        { "octopus",    DEFAULT_OCTOPUS },
+       { "ort",        NO_TRIVIAL },
        { "resolve",    0 },
        { "ours",       NO_FAST_FORWARD | NO_TRIVIAL },
        { "subtree",    NO_FAST_FORWARD | NO_TRIVIAL },
@@ -160,10 +162,17 @@ static struct strategy *get_strategy(const char *name)
        struct strategy *ret;
        static struct cmdnames main_cmds, other_cmds;
        static int loaded;
+       char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM");
 
        if (!name)
                return NULL;
 
+       if (default_strategy &&
+           !strcmp(default_strategy, "ort") &&
+           !strcmp(name, "recursive")) {
+               name = "ort";
+       }
+
        for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
                if (!strcmp(name, all_strategy[i].name))
                        return &all_strategy[i];
@@ -290,7 +299,7 @@ static struct option builtin_merge_options[] = {
          N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
        OPT_AUTOSTASH(&autostash),
        OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")),
-       OPT_BOOL(0, "signoff", &signoff, N_("add Signed-off-by:")),
+       OPT_BOOL(0, "signoff", &signoff, N_("add a Signed-off-by trailer")),
        OPT_BOOL(0, "no-verify", &no_verify, N_("bypass pre-merge-commit and commit-msg hooks")),
        OPT_END()
 };
@@ -702,7 +711,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
        if (refresh_and_write_cache(REFRESH_QUIET, SKIP_IF_UNCHANGED, 0) < 0)
                return error(_("Unable to write index."));
 
-       if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree")) {
+       if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree") ||
+           !strcmp(strategy, "ort")) {
                struct lock_file lock = LOCK_INIT;
                int clean, x;
                struct commit *result;
@@ -733,8 +743,12 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                        commit_list_insert(j->item, &reversed);
 
                hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
-               clean = merge_recursive(&o, head,
-                               remoteheads->item, reversed, &result);
+               if (!strcmp(strategy, "ort"))
+                       clean = merge_ort_recursive(&o, head, remoteheads->item,
+                                                   reversed, &result);
+               else
+                       clean = merge_recursive(&o, head, remoteheads->item,
+                                               reversed, &result);
                if (clean < 0)
                        exit(128);
                if (write_locked_index(&the_index, &lock,
@@ -1265,6 +1279,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
        if (branch)
                skip_prefix(branch, "refs/heads/", &branch);
 
+       if (!pull_twohead) {
+               char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM");
+               if (default_strategy && !strcmp(default_strategy, "ort"))
+                       pull_twohead = "ort";
+       }
+
        init_diff_ui_defaults();
        git_config(git_merge_config, NULL);