Skip to content

Commit 2e806d8

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 77c0294 commit 2e806d8

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

Documentation/merge-strategies.adoc

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

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+
90104
subtree[=<path>];;
91105
This option is a more advanced form of 'subtree' strategy, where
92106
the strategy makes a guess on how two trees must be shifted to
@@ -111,20 +125,7 @@ recursive::
111125
For a path that is a submodule, the same caution as 'ort' applies to this
112126
strategy.
113127
+
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'.
128129

129130
resolve::
130131
This can only resolve two heads (i.e. the current branch

merge-ort.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4957,9 +4957,6 @@ static void merge_start(struct merge_options *opt, struct merge_result *result)
49574957
}
49584958
trace2_region_leave("merge", "sanity checks", opt->repo);
49594959

4960-
/* Default to histogram diff. Actually, just hardcode it...for now. */
4961-
opt->xdl_opts = DIFF_WITH_ALG(opt, HISTOGRAM_DIFF);
4962-
49634960
/* Handle attr direction stuff for renormalization */
49644961
if (opt->renormalize)
49654962
git_attr_set_direction(GIT_ATTR_CHECKOUT);

merge-recursive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3981,6 +3981,7 @@ static void init_merge_options(struct merge_options *opt,
39813981
opt->renormalize = 0;
39823982

39833983
opt->conflict_style = -1;
3984+
opt->xdl_opts = DIFF_WITH_ALG(opt, HISTOGRAM_DIFF);
39843985

39853986
merge_recursive_config(opt, ui);
39863987
merge_verbosity = getenv("GIT_MERGE_VERBOSITY");

0 commit comments

Comments
 (0)