]> git.ipfire.org Git - thirdparty/git.git/commitdiff
am: switch from merge_recursive_generic() to merge_ort_generic()
authorElijah Newren <newren@gmail.com>
Thu, 13 Mar 2025 02:46:41 +0000 (02:46 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Mar 2025 16:49:08 +0000 (09:49 -0700)
Switch from merge-recursive to merge-ort.  Adjust the following
testcases due to the switch:

* t4151: This test left an untracked file in the way of the merge.
  merge-recursive could only sometimes tell when untracked files were
  in the way, and by the time it discovers others, it has already made
  too many changes to back out of the merge.  So, instead of writing the
  results to e.g. 'file1' it would instead write them to
  'file1~branch1'.  This is confusing for users, because they might not
  notice 'file1~branch1' and accidentally add and commit 'file1'.
  In contrast, merge-ort correctly notices the file in the way before
  making any changes and aborts.  Since this test didn't care about the
  file in the way, just remove it before calling git-am.

* t4255: Usage of merge-ort allows us to change two known failures into
  successes.

* t6427: As noted a few commits ago, the choice of conflict label for
  diff3 markers for the ancestor commit was previously handled by
  merge-recursive.c rather than by callers.  Since that has now changed,
  `git am` needs to specify that label.  Although the previous conflict
  label ("constructed merge base") was already fairly somewhat slanted
  towards `git am`, let's use wording more along the lines of the
  related command-line flag from `git apply` and function involved to
  tie it more closely to `git am`.

Signed-off-by: Elijah Newren <newren@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
t/t4151-am-abort.sh
t/t4255-am-submodule.sh
t/t6427-diff3-conflict-markers.sh

index 2921bb89ef16e6d050b07c325f0da488d805d9c6..3b61bd4c333c4b791aad8c33972ccf6d34c1711e 100644 (file)
@@ -31,7 +31,7 @@
 #include "preload-index.h"
 #include "sequencer.h"
 #include "revision.h"
-#include "merge-recursive.h"
+#include "merge-ort-wrappers.h"
 #include "log-tree.h"
 #include "notes-utils.h"
 #include "rerere.h"
@@ -1638,12 +1638,13 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
        o.branch1 = "HEAD";
        their_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg);
        o.branch2 = their_tree_name;
+       o.ancestor = "constructed fake ancestor";
        o.detect_directory_renames = MERGE_DIRECTORY_RENAMES_NONE;
 
        if (state->quiet)
                o.verbosity = 0;
 
-       if (merge_recursive_generic(&o, &our_tree, &their_tree, 1, bases, &result)) {
+       if (merge_ort_generic(&o, &our_tree, &their_tree, 1, bases, &result)) {
                repo_rerere(the_repository, state->allow_rerere_autoupdate);
                free(their_tree_name);
                return error(_("Failed to merge in the changes."));
index edb38da7010d33315f02a345a076ef803d460a32..8e1ecf8a68546c5d900a7abedf4eb8fec4743ae3 100755 (executable)
@@ -112,7 +112,7 @@ test_expect_success 'am --abort will keep dirty index intact' '
 test_expect_success 'am -3 stops on conflict on unborn branch' '
        git checkout -f --orphan orphan &&
        git reset &&
-       rm -f otherfile-4 &&
+       rm -f file-1 otherfile-4 &&
        test_must_fail git am -3 0003-*.patch &&
        test 2 -eq $(git ls-files -u | wc -l) &&
        test 4 = "$(cat otherfile-4)"
index a7ba08f728c0b870bf899ee82220a1708699dcb0..e6679a01b4413ad51fba11c54297877253ff5360 100755 (executable)
@@ -19,7 +19,6 @@ am_3way () {
        $2 git am --3way patch
 }
 
-KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
 test_submodule_switch_func "am_3way"
 
 test_expect_success 'setup diff.submodule' '
index dd5fe6a402196270fba03fadff55d1e39fa64f02..57569c4f4bd2fffcb3855f2ea3e64aad482fb71c 100755 (executable)
@@ -207,7 +207,7 @@ test_expect_success 'rebase --apply describes fake ancestor base' '
                cd rebase &&
                git rebase --abort &&
                test_must_fail git -c merge.conflictstyle=diff3 rebase --apply main &&
-               grep "||||||| constructed merge base" file
+               grep "||||||| constructed fake ancestor" file
        )
 '