Skip to content

Commit c3ebf18

Browse files
committed
Merge branch 'en/merge-recursive-debug'
Remove remnants of the recursive merge strategy backend, which was superseded by the ort merge strategy. * en/merge-recursive-debug: builtin/{merge,rebase,revert}: remove GIT_TEST_MERGE_ALGORITHM tests: remove GIT_TEST_MERGE_ALGORITHM and test_expect_merge_algorithm merge-recursive.[ch]: thoroughly debug these merge, sequencer: switch recursive merges over to ort sequencer: switch non-recursive merges over to ort merge-ort: enable diff-algorithms other than histogram builtin/merge-recursive: switch to using merge_ort_generic() checkout: replace merge_trees() with merge_ort_nonrecursive()
2 parents fe7ae3b + 170e30d commit c3ebf18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+538
-5241
lines changed

Documentation/merge-strategies.adoc

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,44 +87,33 @@ no-renames;;
8787
configuration variable.
8888
See also linkgit:git-diff[1] `--no-renames`.
8989

90-
subtree[=<path>];;
91-
This option is a more advanced form of 'subtree' strategy, where
92-
the strategy makes a guess on how two trees must be shifted to
93-
match with each other when merging. Instead, the specified path
94-
is prefixed (or stripped from the beginning) to make the shape of
95-
two trees to match.
96-
97-
recursive::
98-
This can only resolve two heads using a 3-way merge
99-
algorithm. When there is more than one common
100-
ancestor that can be used for 3-way merge, it creates a
101-
merged tree of the common ancestors and uses that as
102-
the reference tree for the 3-way merge. This has been
103-
reported to result in fewer merge conflicts without
104-
causing mismerges by tests done on actual merge commits
105-
taken from Linux 2.6 kernel development history.
106-
Additionally this can detect and handle merges involving
107-
renames. It does not make use of detected copies. This was
108-
the default strategy for resolving two heads from Git v0.99.9k
109-
until v2.33.0.
110-
+
111-
For a path that is a submodule, the same caution as 'ort' applies to this
112-
strategy.
113-
+
114-
The 'recursive' strategy takes the same options as 'ort'. However,
115-
there are two additional options that 'ort' ignores (not documented
116-
above) that are potentially useful with the 'recursive' strategy:
90+
histogram;;
91+
Deprecated synonym for `diff-algorithm=histogram`.
11792

11893
patience;;
11994
Deprecated synonym for `diff-algorithm=patience`.
12095

121-
diff-algorithm=[patience|minimal|histogram|myers];;
96+
diff-algorithm=[histogram|minimal|myers|patience];;
12297
Use a different diff algorithm while merging, which can help
12398
avoid mismerges that occur due to unimportant matching lines
12499
(such as braces from distinct functions). See also
125100
linkgit:git-diff[1] `--diff-algorithm`. Note that `ort`
126-
specifically uses `diff-algorithm=histogram`, while `recursive`
127-
defaults to the `diff.algorithm` config setting.
101+
defaults to `diff-algorithm=histogram`, while regular diffs
102+
currently default to the `diff.algorithm` config setting.
103+
104+
subtree[=<path>];;
105+
This option is a more advanced form of 'subtree' strategy, where
106+
the strategy makes a guess on how two trees must be shifted to
107+
match with each other when merging. Instead, the specified path
108+
is prefixed (or stripped from the beginning) to make the shape of
109+
two trees to match.
110+
111+
recursive::
112+
This is now a synonym for `ort`. It was an alternative
113+
implementation until v2.49.0, but was redirected to mean `ort`
114+
in v2.50.0. The previous recursive strategy was the default
115+
strategy for resolving two heads from Git v0.99.9k until
116+
v2.33.0.
128117

129118
resolve::
130119
This can only resolve two heads (i.e. the current branch
@@ -145,7 +134,7 @@ ours::
145134
ignoring all changes from all other branches. It is meant to
146135
be used to supersede old development history of side
147136
branches. Note that this is different from the -Xours option to
148-
the 'recursive' merge strategy.
137+
the 'ort' merge strategy.
149138

150139
subtree::
151140
This is a modified `ort` strategy. When merging trees A and

Documentation/technical/sparse-checkout.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@ understanding these differences can be beneficial.
356356
The behavior for these commands somewhat depends upon the merge
357357
strategy being used:
358358
* `ort` behaves as described above
359-
* `recursive` tries to not vivify files unnecessarily, but does sometimes
360-
vivify files without conflicts.
361359
* `octopus` and `resolve` will always vivify any file changed in the merge
362360
relative to the first parent, which is rather suboptimal.
363361

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,6 @@ LIB_OBJS += merge-blobs.o
10701070
LIB_OBJS += merge-ll.o
10711071
LIB_OBJS += merge-ort.o
10721072
LIB_OBJS += merge-ort-wrappers.o
1073-
LIB_OBJS += merge-recursive.o
10741073
LIB_OBJS += merge.o
10751074
LIB_OBJS += midx.o
10761075
LIB_OBJS += midx-write.o

builtin/checkout.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "merge-ll.h"
1818
#include "lockfile.h"
1919
#include "mem-pool.h"
20-
#include "merge-recursive.h"
20+
#include "merge-ort-wrappers.h"
2121
#include "object-name.h"
2222
#include "object-store-ll.h"
2323
#include "parse-options.h"
@@ -907,10 +907,10 @@ static int merge_working_tree(const struct checkout_opts *opts,
907907
o.branch1 = new_branch_info->name;
908908
o.branch2 = "local";
909909
o.conflict_style = opts->conflict_style;
910-
ret = merge_trees(&o,
911-
new_tree,
912-
work,
913-
old_tree);
910+
ret = merge_ort_nonrecursive(&o,
911+
new_tree,
912+
work,
913+
old_tree);
914914
if (ret < 0)
915915
exit(128);
916916
ret = reset_tree(new_tree,

builtin/merge-recursive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "advice.h"
44
#include "gettext.h"
55
#include "hash.h"
6-
#include "merge-recursive.h"
6+
#include "merge-ort-wrappers.h"
77
#include "object-name.h"
88

99
static const char builtin_merge_recursive_usage[] =
@@ -89,7 +89,7 @@ int cmd_merge_recursive(int argc,
8989
if (o.verbosity >= 3)
9090
printf(_("Merging %s with %s\n"), o.branch1, o.branch2);
9191

92-
failed = merge_recursive_generic(&o, &h1, &h2, bases_count, bases, &result);
92+
failed = merge_ort_generic(&o, &h1, &h2, bases_count, bases, &result);
9393

9494
free(better1);
9595
free(better2);

builtin/merge.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "rerere.h"
4040
#include "help.h"
4141
#include "merge.h"
42-
#include "merge-recursive.h"
4342
#include "merge-ort-wrappers.h"
4443
#include "resolve-undo.h"
4544
#include "remote.h"
@@ -171,7 +170,7 @@ static struct strategy *get_strategy(const char *name)
171170
struct strategy *ret;
172171
static struct cmdnames main_cmds = {0}, other_cmds = {0};
173172
static int loaded;
174-
char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM");
173+
char *default_strategy = NULL;
175174

176175
if (!name)
177176
return NULL;
@@ -750,12 +749,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
750749

751750
repo_hold_locked_index(the_repository, &lock,
752751
LOCK_DIE_ON_ERROR);
753-
if (!strcmp(strategy, "ort"))
754-
clean = merge_ort_recursive(&o, head, remoteheads->item,
755-
reversed, &result);
756-
else
757-
clean = merge_recursive(&o, head, remoteheads->item,
758-
reversed, &result);
752+
clean = merge_ort_recursive(&o, head, remoteheads->item,
753+
reversed, &result);
759754
free_commit_list(reversed);
760755
strbuf_release(&o.obuf);
761756

@@ -1316,12 +1311,6 @@ int cmd_merge(int argc,
13161311
if (branch)
13171312
skip_prefix(branch, "refs/heads/", &branch);
13181313

1319-
if (!pull_twohead) {
1320-
char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM");
1321-
if (default_strategy && !strcmp(default_strategy, "ort"))
1322-
pull_twohead = xstrdup("ort");
1323-
}
1324-
13251314
init_diff_ui_defaults();
13261315
git_config(git_merge_config, NULL);
13271316

@@ -1522,12 +1511,6 @@ int cmd_merge(int argc,
15221511
fast_forward = FF_NO;
15231512
}
15241513

1525-
if (!use_strategies && !pull_twohead &&
1526-
remoteheads && !remoteheads->next) {
1527-
char *default_strategy = getenv("GIT_TEST_MERGE_ALGORITHM");
1528-
if (default_strategy)
1529-
append_strategy(get_strategy(default_strategy));
1530-
}
15311514
if (!use_strategies) {
15321515
if (!remoteheads)
15331516
; /* already up-to-date */

builtin/rebase.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,11 +1575,6 @@ int cmd_rebase(int argc,
15751575
options.default_backend);
15761576
}
15771577

1578-
if (options.type == REBASE_MERGE &&
1579-
!options.strategy &&
1580-
getenv("GIT_TEST_MERGE_ALGORITHM"))
1581-
options.strategy = xstrdup(getenv("GIT_TEST_MERGE_ALGORITHM"));
1582-
15831578
switch (options.type) {
15841579
case REBASE_MERGE:
15851580
options.state_dir = merge_dir();

builtin/revert.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,6 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,
252252
free(opts->strategy);
253253
opts->strategy = xstrdup_or_null(strategy);
254254
}
255-
if (!opts->strategy && getenv("GIT_TEST_MERGE_ALGORITHM"))
256-
opts->strategy = xstrdup(getenv("GIT_TEST_MERGE_ALGORITHM"));
257255
free(options);
258256

259257
if (cmd == 'q') {

ci/run-build-and-tests.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ linux-breaking-changes)
2020
linux-TEST-vars)
2121
export OPENSSL_SHA1_UNSAFE=YesPlease
2222
export GIT_TEST_SPLIT_INDEX=yes
23-
export GIT_TEST_MERGE_ALGORITHM=recursive
2423
export GIT_TEST_FULL_IN_PACK_ARRAY=true
2524
export GIT_TEST_OE_SIZE=10
2625
export GIT_TEST_OE_DELTA_SIZE=5

merge-ort-wrappers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef MERGE_ORT_WRAPPERS_H
22
#define MERGE_ORT_WRAPPERS_H
33

4-
#include "merge-recursive.h"
4+
#include "merge-ort.h"
55

66
/*
77
* rename-detecting three-way merge, no recursion.

0 commit comments

Comments
 (0)