From 883f763bc6724efde734f35f5411e0361bcb69c1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 13 Jul 2024 20:00:56 -0700 Subject: [PATCH] Revert "Merge branch 'ad/merge-with-diff-algorithm' into next" This reverts commit 2a221341d9b66d14d948b71e4edd3494e5dd692c, reversing changes made to cec8ebb668eb0cb093b07f84072b32cce6b1682f. --- builtin/am.c | 2 +- builtin/checkout.c | 2 +- builtin/merge-recursive.c | 2 +- builtin/merge-tree.c | 2 +- builtin/merge.c | 2 +- builtin/replay.c | 2 +- builtin/stash.c | 2 +- log-tree.c | 2 +- merge-recursive.c | 29 ++++--------------------- merge-recursive.h | 5 +---- sequencer.c | 4 ++-- t/t3515-cherry-pick-diff.sh | 41 ----------------------------------- t/t3515/base.c | 17 --------------- t/t3515/ours.c | 17 --------------- t/t3515/theirs.c | 17 --------------- t/t7615-merge-diff.sh | 43 ------------------------------------- 16 files changed, 15 insertions(+), 174 deletions(-) delete mode 100755 t/t3515-cherry-pick-diff.sh delete mode 100644 t/t3515/base.c delete mode 100644 t/t3515/ours.c delete mode 100644 t/t3515/theirs.c delete mode 100755 t/t7615-merge-diff.sh diff --git a/builtin/am.c b/builtin/am.c index a12be088f7..370f5593f2 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1630,7 +1630,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa * changes. */ - init_ui_merge_options(&o, the_repository); + init_merge_options(&o, the_repository); o.branch1 = "HEAD"; their_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg); diff --git a/builtin/checkout.c b/builtin/checkout.c index 5769efaca0..3cf44b4683 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -884,7 +884,7 @@ static int merge_working_tree(const struct checkout_opts *opts, add_files_to_cache(the_repository, NULL, NULL, NULL, 0, 0); - init_ui_merge_options(&o, the_repository); + init_merge_options(&o, the_repository); o.verbosity = 0; work = write_in_core_index_as_tree(the_repository); diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c index e951b09805..82bebea15b 100644 --- a/builtin/merge-recursive.c +++ b/builtin/merge-recursive.c @@ -31,7 +31,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix UNUSED) char *better1, *better2; struct commit *result; - init_basic_merge_options(&o, the_repository); + init_merge_options(&o, the_repository); if (argv[0] && ends_with(argv[0], "-subtree")) o.subtree_shift = ""; diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index 9bca9b5f33..dab2fdc2a6 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -571,7 +571,7 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix) }; /* Init merge options */ - init_ui_merge_options(&o.merge_options, the_repository); + init_merge_options(&o.merge_options, the_repository); /* Parse arguments */ original_argc = argc - 1; /* ignoring argv[0] */ diff --git a/builtin/merge.c b/builtin/merge.c index c896b18d1a..9fba27d85d 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -724,7 +724,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, return 2; } - init_ui_merge_options(&o, the_repository); + init_merge_options(&o, the_repository); if (!strcmp(strategy, "subtree")) o.subtree_shift = ""; diff --git a/builtin/replay.c b/builtin/replay.c index 9acf51c32b..0448326636 100644 --- a/builtin/replay.c +++ b/builtin/replay.c @@ -377,7 +377,7 @@ int cmd_replay(int argc, const char **argv, const char *prefix) goto cleanup; } - init_basic_merge_options(&merge_opt, the_repository); + init_merge_options(&merge_opt, the_repository); memset(&result, 0, sizeof(result)); merge_opt.show_rename_progress = 0; last_commit = onto; diff --git a/builtin/stash.c b/builtin/stash.c index fb75ca219e..46b981c4dd 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -574,7 +574,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, } } - init_ui_merge_options(&o, the_repository); + init_merge_options(&o, the_repository); o.branch1 = "Updated upstream"; o.branch2 = "Stashed changes"; diff --git a/log-tree.c b/log-tree.c index 576ef30d90..52feec4356 100644 --- a/log-tree.c +++ b/log-tree.c @@ -1025,7 +1025,7 @@ static int do_remerge_diff(struct rev_info *opt, struct strbuf parent2_desc = STRBUF_INIT; /* Setup merge options */ - init_ui_merge_options(&o, the_repository); + init_merge_options(&o, the_repository); o.show_rename_progress = 0; o.record_conflict_msgs_as_headers = 1; o.msg_header_prefix = "remerge"; diff --git a/merge-recursive.c b/merge-recursive.c index ed64a4c537..5cc638066a 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -3921,7 +3921,7 @@ int merge_recursive_generic(struct merge_options *opt, return clean ? 0 : 1; } -static void merge_recursive_config(struct merge_options *opt, int ui) +static void merge_recursive_config(struct merge_options *opt) { char *value = NULL; int renormalize = 0; @@ -3950,20 +3950,11 @@ static void merge_recursive_config(struct merge_options *opt, int ui) } /* avoid erroring on values from future versions of git */ free(value); } - if (ui) { - if (!git_config_get_string("diff.algorithm", &value)) { - long diff_algorithm = parse_algorithm_value(value); - if (diff_algorithm < 0) - die(_("unknown value for config '%s': %s"), "diff.algorithm", value); - opt->xdl_opts = (opt->xdl_opts & ~XDF_DIFF_ALGORITHM_MASK) | diff_algorithm; - free(value); - } - } git_config(git_xmerge_config, NULL); } -static void init_merge_options(struct merge_options *opt, - struct repository *repo, int ui) +void init_merge_options(struct merge_options *opt, + struct repository *repo) { const char *merge_verbosity; memset(opt, 0, sizeof(struct merge_options)); @@ -3982,7 +3973,7 @@ static void init_merge_options(struct merge_options *opt, opt->conflict_style = -1; - merge_recursive_config(opt, ui); + merge_recursive_config(opt); merge_verbosity = getenv("GIT_MERGE_VERBOSITY"); if (merge_verbosity) opt->verbosity = strtol(merge_verbosity, NULL, 10); @@ -3990,18 +3981,6 @@ static void init_merge_options(struct merge_options *opt, opt->buffer_output = 0; } -void init_ui_merge_options(struct merge_options *opt, - struct repository *repo) -{ - init_merge_options(opt, repo, 1); -} - -void init_basic_merge_options(struct merge_options *opt, - struct repository *repo) -{ - init_merge_options(opt, repo, 0); -} - /* * For now, members of merge_options do not need deep copying, but * it may change in the future, in which case we would need to update diff --git a/merge-recursive.h b/merge-recursive.h index 0b91f28f90..3136c7cc2d 100644 --- a/merge-recursive.h +++ b/merge-recursive.h @@ -54,10 +54,7 @@ struct merge_options { struct merge_options_internal *priv; }; -/* for use by porcelain commands */ -void init_ui_merge_options(struct merge_options *opt, struct repository *repo); -/* for use by plumbing commands */ -void init_basic_merge_options(struct merge_options *opt, struct repository *repo); +void init_merge_options(struct merge_options *opt, struct repository *repo); void copy_merge_options(struct merge_options *dst, struct merge_options *src); void clear_merge_options(struct merge_options *opt); diff --git a/sequencer.c b/sequencer.c index 0291920f0b..a2284ac9e9 100644 --- a/sequencer.c +++ b/sequencer.c @@ -762,7 +762,7 @@ static int do_recursive_merge(struct repository *r, repo_read_index(r); - init_ui_merge_options(&o, r); + init_merge_options(&o, r); o.ancestor = base ? base_label : "(empty tree)"; o.branch1 = "HEAD"; o.branch2 = next ? next_label : "(empty tree)"; @@ -4309,7 +4309,7 @@ static int do_merge(struct repository *r, bases = reverse_commit_list(bases); repo_read_index(r); - init_ui_merge_options(&o, r); + init_merge_options(&o, r); o.branch1 = "HEAD"; o.branch2 = ref_name.buf; o.buffer_output = 2; diff --git a/t/t3515-cherry-pick-diff.sh b/t/t3515-cherry-pick-diff.sh deleted file mode 100755 index caeaa01c59..0000000000 --- a/t/t3515-cherry-pick-diff.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -test_description='git cherry-pick - -Testing the influence of the diff algorithm on the merge output.' - -TEST_PASSES_SANITIZE_LEAK=true -. ./test-lib.sh - -test_expect_success 'setup' ' - cp "$TEST_DIRECTORY"/t3515/base.c file.c && - git add file.c && - git commit -m c0 && - git tag c0 && - cp "$TEST_DIRECTORY"/t3515/ours.c file.c && - git add file.c && - git commit -m c1 && - git tag c1 && - git reset --hard c0 && - cp "$TEST_DIRECTORY"/t3515/theirs.c file.c && - git add file.c && - git commit -m c2 && - git tag c2 -' - -test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy fails with the current default myers diff algorithm' ' - git reset --hard c1 && - test_must_fail git cherry-pick -s recursive c2 -' - -test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy succeeds with -Xdiff-algorithm=histogram' ' - git reset --hard c1 && - git cherry-pick --strategy recursive -Xdiff-algorithm=histogram c2 -' - -test_expect_success 'cherry-pick c2 to c1 with recursive merge strategy succeeds with diff.algorithm = histogram' ' - git reset --hard c1 && - git config diff.algorithm histogram && - git cherry-pick --strategy recursive c2 -' -test_done diff --git a/t/t3515/base.c b/t/t3515/base.c deleted file mode 100644 index c64abc5936..0000000000 --- a/t/t3515/base.c +++ /dev/null @@ -1,17 +0,0 @@ -int f(int x, int y) -{ - if (x == 0) - { - return y; - } - return x; -} - -int g(size_t u) -{ - while (u < 30) - { - u++; - } - return u; -} diff --git a/t/t3515/ours.c b/t/t3515/ours.c deleted file mode 100644 index 44d8251397..0000000000 --- a/t/t3515/ours.c +++ /dev/null @@ -1,17 +0,0 @@ -int g(size_t u) -{ - while (u < 30) - { - u++; - } - return u; -} - -int h(int x, int y, int z) -{ - if (z == 0) - { - return x; - } - return y; -} diff --git a/t/t3515/theirs.c b/t/t3515/theirs.c deleted file mode 100644 index 85f02146fe..0000000000 --- a/t/t3515/theirs.c +++ /dev/null @@ -1,17 +0,0 @@ -int f(int x, int y) -{ - if (x == 0) - { - return y; - } - return x; -} - -int g(size_t u) -{ - while (u > 34) - { - u--; - } - return u; -} diff --git a/t/t7615-merge-diff.sh b/t/t7615-merge-diff.sh deleted file mode 100755 index be335c7c3d..0000000000 --- a/t/t7615-merge-diff.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -test_description='git merge - -Testing the influence of the diff algorithm on the merge output.' - -TEST_PASSES_SANITIZE_LEAK=true -. ./test-lib.sh - -test_expect_success 'setup' ' - cp "$TEST_DIRECTORY"/t3515/base.c file.c && - git add file.c && - git commit -m c0 && - git tag c0 && - cp "$TEST_DIRECTORY"/t3515/ours.c file.c && - git add file.c && - git commit -m c1 && - git tag c1 && - git reset --hard c0 && - cp "$TEST_DIRECTORY"/t3515/theirs.c file.c && - git add file.c && - git commit -m c2 && - git tag c2 -' - -GIT_TEST_MERGE_ALGORITHM=recursive - -test_expect_success 'merge c2 to c1 with recursive merge strategy fails with the current default myers diff algorithm' ' - git reset --hard c1 && - test_must_fail git merge -s recursive c2 -' - -test_expect_success 'merge c2 to c1 with recursive merge strategy succeeds with -Xdiff-algorithm=histogram' ' - git reset --hard c1 && - git merge --strategy recursive -Xdiff-algorithm=histogram c2 -' - -test_expect_success 'merge c2 to c1 with recursive merge strategy succeeds with diff.algorithm = histogram' ' - git reset --hard c1 && - git config diff.algorithm histogram && - git merge --strategy recursive c2 -' -test_done