merge-ort: enable diff-algorithms other than histogram
The ort merge strategy has always used the histogram diff algorithm. The recursive merge strategy, in contrast, defaults to the myers diff algorithm, while allowing it to be changed. Change the ort merge strategy to allow different diff algorithms, by removing the hard coded value in merge_start() and instead just making it a default in init_merge_options(). Technically, this also changes the default diff algorithm for the recursive backend too, but we're going to remove the final callers of the recursive backend in the next two commits. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Apr 8, 2025 at 15:48 UTC
2e806d8464decacc307cdbfa45c98be8e28382da
3 files changed
+16
-17
Documentation/merge-strategies.adoc
+15
-14
@@ -87,6 +87,20 @@ no-renames;;
87
configuration variable.
88
See also linkgit:git-diff[1] `--no-renames`.
89
90
+histogram;;
91
+ Deprecated synonym for `diff-algorithm=histogram`.
92
+
93
+patience;;
94
+ Deprecated synonym for `diff-algorithm=patience`.
95
+
96
+diff-algorithm=[histogram|minimal|myers|patience];;
97
+ Use a different diff algorithm while merging, which can help
98
+ avoid mismerges that occur due to unimportant matching lines
99
+ (such as braces from distinct functions). See also
100
+ linkgit:git-diff[1] `--diff-algorithm`. Note that `ort`
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
@@ -111,20 +125,7 @@ recursive::
125
For a path that is a submodule, the same caution as 'ort' applies to this
126
strategy.
127
+
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:
117
-
118
-patience;;
119
- Deprecated synonym for `diff-algorithm=patience`.
120
-
121
-diff-algorithm=[patience|minimal|histogram|myers];;
122
- Use a different diff algorithm while merging, which can help
123
- avoid mismerges that occur due to unimportant matching lines
124
- (such as braces from distinct functions). See also
125
- 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.
128
+The 'recursive' strategy takes the same options as 'ort'.
129
130
resolve::
131
This can only resolve two heads (i.e. the current branch
merge-ort.c
-3
@@ -4957,9 +4957,6 @@ static void merge_start(struct merge_options *opt, struct merge_result *result)
4957
}
4958
trace2_region_leave("merge", "sanity checks", opt->repo);
4959
4960
- /* Default to histogram diff. Actually, just hardcode it...for now. */
4961
- opt->xdl_opts = DIFF_WITH_ALG(opt, HISTOGRAM_DIFF);
4962
-
4960
/* Handle attr direction stuff for renormalization */
4961
if (opt->renormalize)
4962
git_attr_set_direction(GIT_ATTR_CHECKOUT);
merge-recursive.c
+1
@@ -3981,6 +3981,7 @@ static void init_merge_options(struct merge_options *opt,
3981
opt->renormalize = 0;
3982
3983
opt->conflict_style = -1;
3984
+ opt->xdl_opts = DIFF_WITH_ALG(opt, HISTOGRAM_DIFF);
3985
3986
merge_recursive_config(opt, ui);
3987
merge_verbosity = getenv("GIT_MERGE_VERBOSITY");