All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Antonin Delpeuch via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Phillip Wood <phillip.wood123@gmail.com>,
	Antonin Delpeuch <antonin@delpeuch.eu>,
	Antonin Delpeuch <antonin@delpeuch.eu>
Subject: [PATCH] merge-file: warn for implicit 'myers' algorithm
Date: Wed, 03 Jul 2024 14:21:09 +0000	[thread overview]
Message-ID: <pull.1741.git.git.1720016469254.gitgitgadget@gmail.com> (raw)

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

             reply	other threads:[~2024-07-03 14:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 14:21 Antonin Delpeuch via GitGitGadget [this message]
2024-07-03 17:30 ` [PATCH] merge-file: warn for implicit 'myers' algorithm Junio C Hamano
2024-07-03 18:28   ` Antonin Delpeuch
2024-07-03 20:19     ` Junio C Hamano
2024-07-05 17:39       ` Elijah Newren
2024-07-05 20:14         ` Antonin Delpeuch
2024-07-06  6:06         ` Junio C Hamano
2024-07-06 13:30           ` Antonin Delpeuch
2024-07-06 18:06             ` Junio C Hamano

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=pull.1741.git.git.1720016469254.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=antonin@delpeuch.eu \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood123@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.