git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:59 UTC

[PATCH] merge-file: warn for implicit 'myers' algorithm

From
Antonin Delpeuch via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 3, 2024, 14:21 UTC
Message-ID
<pull.1741.git.git.1720016469254.gitgitgadget@gmail.com>
From: Antonin Delpeuch <antonin@delpeuch.eu>

The current default diff algorithm for the merge-file command is 'myers', despite the default for the 'ort' strategy being 'histogram'. Since 2.44.0 it is possible to specify a different diff algorithm via the --diff-algorithm option. As a preparation for changing the default to 'histogram', we warn the user about the different behaviour this may cause.

Signed-off-by: Antonin Delpeuch <antonin@delpeuch.eu>
---
    merge-file: warn for implicit 'myers' algorithm
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1741%2Fwetneb%2Fexplicit_diff_algorithm-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1741/wetneb/explicit_diff_algorithm-v1
Pull-Request: https://github.com/git/git/pull/1741
 builtin/merge-file.c  | 8 ++++++++
 t/t6403-merge-file.sh | 5 +++--
 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 1f987334a31..dce2676415e 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -29,6 +29,8 @@ static int label_cb(const struct option *opt, const char *arg, int unset)
 	return 0;
 }
 
+static int explicit_diff_algorithm = 0;
+
 static int set_diff_algorithm(xpparam_t *xpp,
 			      const char *alg)
 {
@@ -50,6 +52,8 @@ static int diff_algorithm_cb(const struct option *opt,
 		return error(_("option diff-algorithm accepts \"myers\", "
 			       "\"minimal\", \"patience\" and \"histogram\""));
 
+	explicit_diff_algorithm = 1;
+
 	return 0;
 }
 
@@ -103,6 +107,10 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 			return error_errno("failed to redirect stderr to /dev/null");
 	}
 
+	if (!explicit_diff_algorithm) {
+		warning(_("--diff-algorithm not provided, defaulting to \"myers\". This default will change to \"histogram\" in a future version."));
+	}
+
 	if (object_id)
 		setup_git_directory();
 
diff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh
index fb872c5a113..9d0045be955 100755
--- a/t/t6403-merge-file.sh
+++ b/t/t6403-merge-file.sh
@@ -540,8 +540,9 @@ test_expect_success 'merging C files with "myers" diff algorithm creates some sp
 	}
 	EOF
 
-	test_must_fail git merge-file -p --diff3 --diff-algorithm myers ours.c base.c theirs.c >myers_output.c &&
-	test_cmp expect.c myers_output.c
+	test_must_fail git merge-file -p --diff3 ours.c base.c theirs.c >myers_output.c 2> err &&
+	test_cmp expect.c myers_output.c &&
+	grep "diff-algorithm not provided" err
 '
 
 test_expect_success 'merging C files with "histogram" diff algorithm avoids some spurious conflicts' '

base-commit: 06e570c0dfb2a2deb64d217db78e2ec21672f558
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 9 in “merge-file: warn for implicit 'myers' algorithm”
  1. merge-file: warn for implicit 'myers' algorithmAntonin Delpeuch via GitGitGadget, Jul 3, 2024
  2. Junio C HamanoJul 3, 2024
  3. Antonin DelpeuchJul 3, 2024
  4. Junio C HamanoJul 3, 2024
  5. Elijah NewrenJul 5, 2024
  6. Antonin DelpeuchJul 5, 2024
  7. Junio C HamanoJul 6, 2024
  8. Antonin DelpeuchJul 6, 2024
  9. Junio C HamanoJul 6, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.