From: Elijah Newren Date: Tue, 8 Apr 2025 15:48:37 +0000 (+0000) Subject: merge-ort: enable diff-algorithms other than histogram X-Git-Tag: v2.50.0-rc0~97^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e806d8464decacc307cdbfa45c98be8e28382da;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/Documentation/merge-strategies.adoc b/Documentation/merge-strategies.adoc index 59f5ae36cc..8c87dd7021 100644 --- a/Documentation/merge-strategies.adoc +++ b/Documentation/merge-strategies.adoc @@ -87,6 +87,20 @@ no-renames;; configuration variable. See also linkgit:git-diff[1] `--no-renames`. +histogram;; + Deprecated synonym for `diff-algorithm=histogram`. + +patience;; + Deprecated synonym for `diff-algorithm=patience`. + +diff-algorithm=[histogram|minimal|myers|patience];; + Use a different diff algorithm while merging, which can help + avoid mismerges that occur due to unimportant matching lines + (such as braces from distinct functions). See also + linkgit:git-diff[1] `--diff-algorithm`. Note that `ort` + defaults to `diff-algorithm=histogram`, while regular diffs + currently default to the `diff.algorithm` config setting. + subtree[=];; This option is a more advanced form of 'subtree' strategy, where the strategy makes a guess on how two trees must be shifted to @@ -111,20 +125,7 @@ recursive:: For a path that is a submodule, the same caution as 'ort' applies to this strategy. + -The 'recursive' strategy takes the same options as 'ort'. However, -there are two additional options that 'ort' ignores (not documented -above) that are potentially useful with the 'recursive' strategy: - -patience;; - Deprecated synonym for `diff-algorithm=patience`. - -diff-algorithm=[patience|minimal|histogram|myers];; - Use a different diff algorithm while merging, which can help - avoid mismerges that occur due to unimportant matching lines - (such as braces from distinct functions). See also - linkgit:git-diff[1] `--diff-algorithm`. Note that `ort` - specifically uses `diff-algorithm=histogram`, while `recursive` - defaults to the `diff.algorithm` config setting. +The 'recursive' strategy takes the same options as 'ort'. resolve:: This can only resolve two heads (i.e. the current branch diff --git a/merge-ort.c b/merge-ort.c index 2b7d86aa4e..14a7ae4a6b 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -4957,9 +4957,6 @@ static void merge_start(struct merge_options *opt, struct merge_result *result) } trace2_region_leave("merge", "sanity checks", opt->repo); - /* Default to histogram diff. Actually, just hardcode it...for now. */ - opt->xdl_opts = DIFF_WITH_ALG(opt, HISTOGRAM_DIFF); - /* Handle attr direction stuff for renormalization */ if (opt->renormalize) git_attr_set_direction(GIT_ATTR_CHECKOUT); diff --git a/merge-recursive.c b/merge-recursive.c index 884ccf99a5..f3df127ad9 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -3981,6 +3981,7 @@ static void init_merge_options(struct merge_options *opt, opt->renormalize = 0; opt->conflict_style = -1; + opt->xdl_opts = DIFF_WITH_ALG(opt, HISTOGRAM_DIFF); merge_recursive_config(opt, ui); merge_verbosity = getenv("GIT_MERGE_VERBOSITY");