git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Eric Sunshine <sunshine@sunshineco.com>,
	Elijah Newren <newren@gmail.com>,
	Elijah Newren <newren@gmail.com>,
	Elijah Newren <newren@gmail.com>
Subject: [PATCH v2 3/8] merge-ort: enable diff-algorithms other than histogram
Date: Sat, 05 Apr 2025 22:16:09 +0000	[thread overview]
Message-ID: <cf774437123722d6065139573b49c3e09c6c135a.1743891375.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1898.v2.git.1743891374.gitgitgadget@gmail.com>

From: Elijah Newren <newren@gmail.com>

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>
---
 Documentation/merge-strategies.adoc | 29 +++++++++++++++--------------
 merge-ort.c                         |  3 ---
 merge-recursive.c                   |  1 +
 3 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/Documentation/merge-strategies.adoc b/Documentation/merge-strategies.adoc
index 59f5ae36ccb..8c87dd70210 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[=<path>];;
 	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 2b7d86aa4ec..14a7ae4a6bf 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 884ccf99a58..f3df127ad9b 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");
-- 
gitgitgadget


  parent reply	other threads:[~2025-04-05 22:16 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 15:51 [PATCH 0/8] Debug merge-recursive.[ch] Elijah Newren via GitGitGadget
2025-03-31 15:51 ` [PATCH 1/8] checkout: replace merge_trees() with merge_ort_nonrecursive() Elijah Newren via GitGitGadget
2025-03-31 15:51 ` [PATCH 2/8] builtin/merge-recursive: switch to using merge_ort_generic() Elijah Newren via GitGitGadget
2025-03-31 15:51 ` [PATCH 3/8] merge-ort: enable diff-algorithms other than histogram Elijah Newren via GitGitGadget
2025-03-31 15:51 ` [PATCH 4/8] sequencer: switch non-recursive merges over to ort Elijah Newren via GitGitGadget
2025-03-31 15:51 ` [PATCH 5/8] merge, sequencer: switch recursive " Elijah Newren via GitGitGadget
2025-03-31 15:51 ` [PATCH 6/8] merge-recursive.[ch]: thoroughly debug these Elijah Newren via GitGitGadget
2025-03-31 15:51 ` [PATCH 7/8] tests: remove GIT_TEST_MERGE_ALGORITHM and test_expect_merge_algorithm Elijah Newren via GitGitGadget
2025-03-31 17:34   ` Eric Sunshine
2025-03-31 18:14     ` Elijah Newren
2025-03-31 15:51 ` [PATCH 8/8] builtin/{merge,rebase,revert}: remove GIT_TEST_MERGE_ALGORITHM Elijah Newren via GitGitGadget
2025-04-05 22:16 ` [PATCH v2 0/8] Debug merge-recursive.[ch] Elijah Newren via GitGitGadget
2025-04-05 22:16   ` [PATCH v2 1/8] checkout: replace merge_trees() with merge_ort_nonrecursive() Elijah Newren via GitGitGadget
2025-04-05 22:16   ` [PATCH v2 2/8] builtin/merge-recursive: switch to using merge_ort_generic() Elijah Newren via GitGitGadget
2025-04-05 22:16   ` Elijah Newren via GitGitGadget [this message]
2025-04-05 22:16   ` [PATCH v2 4/8] sequencer: switch non-recursive merges over to ort Elijah Newren via GitGitGadget
2025-04-05 22:16   ` [PATCH v2 5/8] merge, sequencer: switch recursive " Elijah Newren via GitGitGadget
2025-04-05 22:16   ` [PATCH v2 6/8] merge-recursive.[ch]: thoroughly debug these Elijah Newren via GitGitGadget
2025-04-05 22:16   ` [PATCH v2 7/8] tests: remove GIT_TEST_MERGE_ALGORITHM and test_expect_merge_algorithm Elijah Newren via GitGitGadget
2025-04-05 22:16   ` [PATCH v2 8/8] builtin/{merge,rebase,revert}: remove GIT_TEST_MERGE_ALGORITHM Elijah Newren via GitGitGadget
2025-04-07 20:09   ` [PATCH v2 0/8] Debug merge-recursive.[ch] Junio C Hamano
2025-04-07 22:23     ` Elijah Newren
2025-04-08 15:48   ` [PATCH v3 " Elijah Newren via GitGitGadget
2025-04-08 15:48     ` [PATCH v3 1/8] checkout: replace merge_trees() with merge_ort_nonrecursive() Elijah Newren via GitGitGadget
2025-04-08 15:48     ` [PATCH v3 2/8] builtin/merge-recursive: switch to using merge_ort_generic() Elijah Newren via GitGitGadget
2025-04-08 15:48     ` [PATCH v3 3/8] merge-ort: enable diff-algorithms other than histogram Elijah Newren via GitGitGadget
2025-04-08 15:48     ` [PATCH v3 4/8] sequencer: switch non-recursive merges over to ort Elijah Newren via GitGitGadget
2025-04-08 15:48     ` [PATCH v3 5/8] merge, sequencer: switch recursive " Elijah Newren via GitGitGadget
2025-04-08 15:48     ` [PATCH v3 6/8] merge-recursive.[ch]: thoroughly debug these Elijah Newren via GitGitGadget
2025-04-08 15:48     ` [PATCH v3 7/8] tests: remove GIT_TEST_MERGE_ALGORITHM and test_expect_merge_algorithm Elijah Newren via GitGitGadget
2025-04-08 15:48     ` [PATCH v3 8/8] builtin/{merge,rebase,revert}: remove GIT_TEST_MERGE_ALGORITHM Elijah Newren via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cf774437123722d6065139573b49c3e09c6c135a.1743891375.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).