Skip to content

Commit 947e219

Browse files
newrengitster
authored andcommitted
am: switch from merge_recursive_generic() to merge_ort_generic()
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 <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a16e8ef commit 947e219

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

builtin/am.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "preload-index.h"
3232
#include "sequencer.h"
3333
#include "revision.h"
34-
#include "merge-recursive.h"
34+
#include "merge-ort-wrappers.h"
3535
#include "log-tree.h"
3636
#include "notes-utils.h"
3737
#include "rerere.h"
@@ -1638,12 +1638,13 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
16381638
o.branch1 = "HEAD";
16391639
their_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg);
16401640
o.branch2 = their_tree_name;
1641+
o.ancestor = "constructed fake ancestor";
16411642
o.detect_directory_renames = MERGE_DIRECTORY_RENAMES_NONE;
16421643

16431644
if (state->quiet)
16441645
o.verbosity = 0;
16451646

1646-
if (merge_recursive_generic(&o, &our_tree, &their_tree, 1, bases, &result)) {
1647+
if (merge_ort_generic(&o, &our_tree, &their_tree, 1, bases, &result)) {
16471648
repo_rerere(the_repository, state->allow_rerere_autoupdate);
16481649
free(their_tree_name);
16491650
return error(_("Failed to merge in the changes."));

t/t4151-am-abort.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ test_expect_success 'am --abort will keep dirty index intact' '
112112
test_expect_success 'am -3 stops on conflict on unborn branch' '
113113
git checkout -f --orphan orphan &&
114114
git reset &&
115-
rm -f otherfile-4 &&
115+
rm -f file-1 otherfile-4 &&
116116
test_must_fail git am -3 0003-*.patch &&
117117
test 2 -eq $(git ls-files -u | wc -l) &&
118118
test 4 = "$(cat otherfile-4)"

t/t4255-am-submodule.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ am_3way () {
1919
$2 git am --3way patch
2020
}
2121

22-
KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
2322
test_submodule_switch_func "am_3way"
2423

2524
test_expect_success 'setup diff.submodule' '

t/t6427-diff3-conflict-markers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ test_expect_success 'rebase --apply describes fake ancestor base' '
207207
cd rebase &&
208208
git rebase --abort &&
209209
test_must_fail git -c merge.conflictstyle=diff3 rebase --apply main &&
210-
grep "||||||| constructed merge base" file
210+
grep "||||||| constructed fake ancestor" file
211211
)
212212
'
213213

0 commit comments

Comments
 (0)