From: Antonin Delpeuch <antonin@xxxxxxxxxxx> 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@xxxxxxxxxxx> --- 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