|
28 | 28 | #include "rerere.h" |
29 | 29 | #include "help.h" |
30 | 30 | #include "merge-recursive.h" |
| 31 | +#include "merge-ort-wrappers.h" |
31 | 32 | #include "resolve-undo.h" |
32 | 33 | #include "remote.h" |
33 | 34 | #include "fmt-merge-msg.h" |
@@ -88,6 +89,7 @@ static int no_verify; |
88 | 89 | static struct strategy all_strategy[] = { |
89 | 90 | { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL }, |
90 | 91 | { "octopus", DEFAULT_OCTOPUS }, |
| 92 | + { "ort", NO_TRIVIAL }, |
91 | 93 | { "resolve", 0 }, |
92 | 94 | { "ours", NO_FAST_FORWARD | NO_TRIVIAL }, |
93 | 95 | { "subtree", NO_FAST_FORWARD | NO_TRIVIAL }, |
@@ -159,10 +161,17 @@ static struct strategy *get_strategy(const char *name) |
159 | 161 | struct strategy *ret; |
160 | 162 | static struct cmdnames main_cmds, other_cmds; |
161 | 163 | static int loaded; |
| 164 | + char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM"); |
162 | 165 |
|
163 | 166 | if (!name) |
164 | 167 | return NULL; |
165 | 168 |
|
| 169 | + if (default_strategy && |
| 170 | + !strcmp(default_strategy, "ort") && |
| 171 | + !strcmp(name, "recursive")) { |
| 172 | + name = "ort"; |
| 173 | + } |
| 174 | + |
166 | 175 | for (i = 0; i < ARRAY_SIZE(all_strategy); i++) |
167 | 176 | if (!strcmp(name, all_strategy[i].name)) |
168 | 177 | return &all_strategy[i]; |
@@ -701,7 +710,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, |
701 | 710 | if (refresh_and_write_cache(REFRESH_QUIET, SKIP_IF_UNCHANGED, 0) < 0) |
702 | 711 | return error(_("Unable to write index.")); |
703 | 712 |
|
704 | | - if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree")) { |
| 713 | + if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree") || |
| 714 | + !strcmp(strategy, "ort")) { |
705 | 715 | struct lock_file lock = LOCK_INIT; |
706 | 716 | int clean, x; |
707 | 717 | struct commit *result; |
@@ -732,8 +742,12 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, |
732 | 742 | commit_list_insert(j->item, &reversed); |
733 | 743 |
|
734 | 744 | hold_locked_index(&lock, LOCK_DIE_ON_ERROR); |
735 | | - clean = merge_recursive(&o, head, |
736 | | - remoteheads->item, reversed, &result); |
| 745 | + if (!strcmp(strategy, "ort")) |
| 746 | + clean = merge_ort_recursive(&o, head, remoteheads->item, |
| 747 | + reversed, &result); |
| 748 | + else |
| 749 | + clean = merge_recursive(&o, head, remoteheads->item, |
| 750 | + reversed, &result); |
737 | 751 | if (clean < 0) |
738 | 752 | exit(128); |
739 | 753 | if (write_locked_index(&the_index, &lock, |
@@ -1264,6 +1278,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix) |
1264 | 1278 | if (branch) |
1265 | 1279 | skip_prefix(branch, "refs/heads/", &branch); |
1266 | 1280 |
|
| 1281 | + if (!pull_twohead) { |
| 1282 | + char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM"); |
| 1283 | + if (default_strategy && !strcmp(default_strategy, "ort")) |
| 1284 | + pull_twohead = "ort"; |
| 1285 | + } |
| 1286 | + |
1267 | 1287 | init_diff_ui_defaults(); |
1268 | 1288 | git_config(git_merge_config, NULL); |
1269 | 1289 |
|
|
0 commit comments