Skip to content

Commit 77c0294

Browse files
newrengitster
authored andcommitted
builtin/merge-recursive: switch to using merge_ort_generic()
Switch from merge-recursive to merge-ort. Adjust the following testcases due to the switch: * t6430: most of the test differences here were due to improved D/F conflict handling explained in more detail in ef52778 (merge tests: expect improved directory/file conflict handling in ort, 2020-10-26). These changes weren't made to this test back in that commit simply because I had been looking at `git merge` rather than `git merge-recursive`. The final test in this testsuite, though, was expunged because it was looking for specific output, and the calls to output_commit_title() were discarded from merge_ort_internal() in its adaptation from merge_recursive_internal(); see 8119214 (merge-ort: implement merge_incore_recursive(), 2020-12-16). * t6434: This test is built entirely around rename/delete conflicts, which had a suboptimal handling under merge-recursive. As explained in more detail in commits 1f3c9ba ("t6425: be more flexible with rename/delete conflict messages", 2020-08-10) and 727c75b ("t6404, t6423: expect improved rename/delete handling in ort backend", 2020-10-26), rename/delete conflicts should each have two entries in the index rather than just one. Adjust the expectations for all the tests in this testcase to see the two entries per rename/delete conflict. * t6424: merge-recursive had a special check-if-toplevel-trees-match check that it ran at the beginning on both the merge-base and the other side being merged in. In such a case, it exited early and printed an "Already up to date." message. merge-ort got rid of this, and instead checks the merge base tree matching the other side throughout the tree instead of just at the toplevel, allowing it to avoid recursing into various subtrees. As part of that, it got rid of the specialty toplevel message. That message hasn't been missed for years from `git merge`, so I don't think it is necessary to keep it just for `git merge-recursive`, especially since the latter is rarely used. (git itself only references it in the testsuite, whereas it used to power one of the three rebase backends that existed once upon a time.) Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b5dff2b commit 77c0294

File tree

4 files changed

+22
-45
lines changed

4 files changed

+22
-45
lines changed

builtin/merge-recursive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "advice.h"
44
#include "gettext.h"
55
#include "hash.h"
6-
#include "merge-recursive.h"
6+
#include "merge-ort-wrappers.h"
77
#include "object-name.h"
88

99
static const char builtin_merge_recursive_usage[] =
@@ -89,7 +89,7 @@ int cmd_merge_recursive(int argc,
8989
if (o.verbosity >= 3)
9090
printf(_("Merging %s with %s\n"), o.branch1, o.branch2);
9191

92-
failed = merge_recursive_generic(&o, &h1, &h2, bases_count, bases, &result);
92+
failed = merge_ort_generic(&o, &h1, &h2, bases_count, bases, &result);
9393

9494
free(better1);
9595
free(better2);

t/t6424-merge-unrelated-index-changes.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ test_expect_success 'merge-recursive, when index==head but head!=HEAD' '
176176
# Make index match B
177177
git diff C B -- | git apply --cached &&
178178
test_when_finished "git clean -fd" && # Do not leave untracked around
179+
git write-tree >index-before &&
179180
# Merge B & F, with B as "head"
180181
git merge-recursive A -- B F > out &&
181-
test_grep "Already up to date" out
182+
git write-tree >index-after &&
183+
test_cmp index-before index-after
182184
'
183185

184186
test_expect_success 'recursive, when file has staged changes not matching HEAD nor what a merge would give' '

t/t6430-merge-recursive.sh

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ test_expect_success 'merge-recursive d/f conflict result' '
373373
374374
git ls-files -s >actual &&
375375
(
376-
echo "100644 $o0 1 a" &&
377-
echo "100644 $o1 2 a" &&
378376
echo "100644 $o4 0 a/c" &&
377+
echo "100644 $o0 1 a~$c1" &&
378+
echo "100644 $o1 2 a~$c1" &&
379379
echo "100644 $o0 0 b" &&
380380
echo "100644 $o0 0 c" &&
381381
echo "100644 $o1 0 d/e"
@@ -397,9 +397,9 @@ test_expect_success 'merge-recursive d/f conflict result the other way' '
397397
398398
git ls-files -s >actual &&
399399
(
400-
echo "100644 $o0 1 a" &&
401-
echo "100644 $o1 3 a" &&
402400
echo "100644 $o4 0 a/c" &&
401+
echo "100644 $o0 1 a~$c1" &&
402+
echo "100644 $o1 3 a~$c1" &&
403403
echo "100644 $o0 0 b" &&
404404
echo "100644 $o0 0 c" &&
405405
echo "100644 $o1 0 d/e"
@@ -424,9 +424,9 @@ test_expect_success 'merge-recursive d/f conflict result' '
424424
echo "100644 $o1 0 a" &&
425425
echo "100644 $o0 0 b" &&
426426
echo "100644 $o0 0 c" &&
427-
echo "100644 $o6 3 d" &&
428427
echo "100644 $o0 1 d/e" &&
429-
echo "100644 $o1 2 d/e"
428+
echo "100644 $o1 2 d/e" &&
429+
echo "100644 $o6 3 d~$c6"
430430
) >expected &&
431431
test_cmp expected actual
432432
@@ -448,9 +448,9 @@ test_expect_success 'merge-recursive d/f conflict result' '
448448
echo "100644 $o1 0 a" &&
449449
echo "100644 $o0 0 b" &&
450450
echo "100644 $o0 0 c" &&
451-
echo "100644 $o6 2 d" &&
452451
echo "100644 $o0 1 d/e" &&
453-
echo "100644 $o1 3 d/e"
452+
echo "100644 $o1 3 d/e" &&
453+
echo "100644 $o6 2 d~$c6"
454454
) >expected &&
455455
test_cmp expected actual
456456
@@ -696,33 +696,6 @@ test_expect_success 'merging with triple rename across D/F conflict' '
696696
git merge other
697697
'
698698

699-
test_expect_success 'merge-recursive remembers the names of all base trees' '
700-
git reset --hard HEAD &&
701-
702-
# make the index match $c1 so that merge-recursive below does not
703-
# fail early
704-
git diff --binary HEAD $c1 -- | git apply --cached &&
705-
706-
# more trees than static slots used by oid_to_hex()
707-
for commit in $c0 $c2 $c4 $c5 $c6 $c7
708-
do
709-
git rev-parse "$commit^{tree}" || return 1
710-
done >trees &&
711-
712-
# ignore the return code; it only fails because the input is weird...
713-
test_must_fail git -c merge.verbosity=5 merge-recursive $(cat trees) -- $c1 $c3 >out &&
714-
715-
# ...but make sure it fails in the expected way
716-
test_grep CONFLICT.*rename/rename out &&
717-
718-
# merge-recursive prints in reverse order, but we do not care
719-
sort <trees >expect &&
720-
sed -n "s/^virtual //p" out | sort >actual &&
721-
test_cmp expect actual &&
722-
723-
git clean -fd
724-
'
725-
726699
test_expect_success 'merge-recursive internal merge resolves to the sameness' '
727700
git reset --hard HEAD &&
728701

t/t6434-merge-recursive-rename-options.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
3434
get_expected_stages () {
3535
git checkout rename -- $1-new &&
3636
git ls-files --stage $1-new >expected-stages-undetected-$1 &&
37-
sed "s/ 0 / 2 /" <expected-stages-undetected-$1 \
37+
git ls-tree HEAD^ $1-old >tmp &&
38+
git ls-tree HEAD $1-new >>tmp &&
39+
cat tmp | awk '{print $1 " " $3 " " NR "\t" '$1'"-new"}' \
3840
>expected-stages-detected-$1 &&
3941
git read-tree -u --reset HEAD
4042
}
@@ -51,43 +53,43 @@ rename_undetected () {
5153

5254
check_common () {
5355
git ls-files --stage >stages-actual &&
54-
test_line_count = 4 stages-actual
56+
test_line_count = $1 stages-actual
5557
}
5658

5759
check_threshold_0 () {
58-
check_common &&
60+
check_common 8 &&
5961
rename_detected 0 &&
6062
rename_detected 1 &&
6163
rename_detected 2 &&
6264
rename_detected 3
6365
}
6466

6567
check_threshold_1 () {
66-
check_common &&
68+
check_common 7 &&
6769
rename_undetected 0 &&
6870
rename_detected 1 &&
6971
rename_detected 2 &&
7072
rename_detected 3
7173
}
7274

7375
check_threshold_2 () {
74-
check_common &&
76+
check_common 6 &&
7577
rename_undetected 0 &&
7678
rename_undetected 1 &&
7779
rename_detected 2 &&
7880
rename_detected 3
7981
}
8082

8183
check_exact_renames () {
82-
check_common &&
84+
check_common 5 &&
8385
rename_undetected 0 &&
8486
rename_undetected 1 &&
8587
rename_undetected 2 &&
8688
rename_detected 3
8789
}
8890

8991
check_no_renames () {
90-
check_common &&
92+
check_common 4 &&
9193
rename_undetected 0 &&
9294
rename_undetected 1 &&
9395
rename_undetected 2 &&

0 commit comments

Comments
 (0)