@@ -3634,28 +3634,35 @@ test_expect_success '11a: Avoid losing dirty contents with simple rename' '
3634
3634
echo stuff >>z/c &&
3635
3635
3636
3636
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3637
- test_i18ngrep "Refusing to lose dirty file at z/c" out &&
3637
+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3638
+ then
3639
+ test_path_is_missing .git/MERGE_HEAD &&
3640
+ test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
3641
+ else
3642
+ test_i18ngrep "Refusing to lose dirty file at z/c" out &&
3638
3643
3639
- test_seq 1 10 >expected &&
3640
- echo stuff >>expected &&
3641
- test_cmp expected z/c &&
3644
+ git ls-files -s >out &&
3645
+ test_line_count = 2 out &&
3646
+ git ls-files -u >out &&
3647
+ test_line_count = 1 out &&
3648
+ git ls-files -o >out &&
3649
+ test_line_count = 3 out &&
3642
3650
3643
- git ls-files -s >out &&
3644
- test_line_count = 2 out &&
3645
- git ls-files -u >out &&
3646
- test_line_count = 1 out &&
3647
- git ls-files -o >out &&
3648
- test_line_count = 4 out &&
3651
+ git rev-parse >actual \
3652
+ :0:z/a :2:z/c &&
3653
+ git rev-parse >expect \
3654
+ O:z/a B:z/b &&
3655
+ test_cmp expect actual &&
3649
3656
3650
- git rev-parse >actual \
3651
- :0:z/a :2:z/c &&
3652
- git rev-parse >expect \
3653
- O:z/a B:z/b &&
3654
- test_cmp expect actual &&
3657
+ git hash-object z/c~HEAD >actual &&
3658
+ git rev-parse B:z/b >expect &&
3659
+ test_cmp expect actual
3660
+ fi &&
3661
+
3662
+ test_seq 1 10 >expected &&
3663
+ echo stuff >>expected &&
3664
+ test_cmp expected z/c
3655
3665
3656
- git hash-object z/c~HEAD >actual &&
3657
- git rev-parse B:z/b >expect &&
3658
- test_cmp expect actual
3659
3666
)
3660
3667
'
3661
3668
@@ -3706,32 +3713,39 @@ test_expect_success '11b: Avoid losing dirty file involved in directory rename'
3706
3713
git checkout A^0 &&
3707
3714
echo stuff >>z/c &&
3708
3715
3709
- git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3710
- test_i18ngrep "Refusing to lose dirty file at z/c" out &&
3716
+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3717
+ then
3718
+ test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3719
+ test_path_is_missing .git/MERGE_HEAD &&
3720
+ test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
3721
+ else
3722
+ git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3723
+ test_i18ngrep "Refusing to lose dirty file at z/c" out &&
3711
3724
3712
- grep -q stuff z/c &&
3713
- test_seq 1 10 >expected &&
3714
- echo stuff >>expected &&
3715
- test_cmp expected z/c &&
3725
+ git ls-files -s >out &&
3726
+ test_line_count = 3 out &&
3727
+ git ls-files -u >out &&
3728
+ test_line_count = 0 out &&
3729
+ git ls-files -m >out &&
3730
+ test_line_count = 0 out &&
3731
+ git ls-files -o >out &&
3732
+ test_line_count = 3 out &&
3716
3733
3717
- git ls-files -s >out &&
3718
- test_line_count = 3 out &&
3719
- git ls-files -u >out &&
3720
- test_line_count = 0 out &&
3721
- git ls-files -m >out &&
3722
- test_line_count = 0 out &&
3723
- git ls-files -o >out &&
3724
- test_line_count = 4 out &&
3734
+ git rev-parse >actual \
3735
+ :0:x/b :0:y/a :0:y/c &&
3736
+ git rev-parse >expect \
3737
+ O:x/b O:z/a B:x/c &&
3738
+ test_cmp expect actual &&
3725
3739
3726
- git rev-parse >actual \
3727
- :0:x/b :0:y/a :0:y/c &&
3728
- git rev-parse >expect \
3729
- O:x/b O:z/a B:x/c &&
3730
- test_cmp expect actual &&
3740
+ git hash-object y/c >actual &&
3741
+ git rev-parse B:x/c >expect &&
3742
+ test_cmp expect actual
3743
+ fi &&
3731
3744
3732
- git hash-object y/c >actual &&
3733
- git rev-parse B:x/c >expect &&
3734
- test_cmp expect actual
3745
+ grep -q stuff z/c &&
3746
+ test_seq 1 10 >expected &&
3747
+ echo stuff >>expected &&
3748
+ test_cmp expected z/c
3735
3749
)
3736
3750
'
3737
3751
@@ -3783,7 +3797,13 @@ test_expect_success '11c: Avoid losing not-uptodate with rename + D/F conflict'
3783
3797
echo stuff >>y/c &&
3784
3798
3785
3799
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3786
- test_i18ngrep "following files would be overwritten by merge" err &&
3800
+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3801
+ then
3802
+ test_path_is_missing .git/MERGE_HEAD &&
3803
+ test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
3804
+ else
3805
+ test_i18ngrep "following files would be overwritten by merge" err
3806
+ fi &&
3787
3807
3788
3808
grep -q stuff y/c &&
3789
3809
test_seq 1 10 >expected &&
@@ -3851,29 +3871,35 @@ test_expect_success '11d: Avoid losing not-uptodate with rename + D/F conflict'
3851
3871
echo stuff >>z/c &&
3852
3872
3853
3873
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3854
- test_i18ngrep "Refusing to lose dirty file at z/c" out &&
3874
+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3875
+ then
3876
+ test_path_is_missing .git/MERGE_HEAD &&
3877
+ test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
3878
+ else
3879
+ test_i18ngrep "Refusing to lose dirty file at z/c" out &&
3855
3880
3856
- grep -q stuff z/c &&
3857
- test_seq 1 10 >expected &&
3858
- echo stuff >>expected &&
3859
- test_cmp expected z/c &&
3881
+ git ls-files -s >out &&
3882
+ test_line_count = 4 out &&
3883
+ git ls-files -u >out &&
3884
+ test_line_count = 1 out &&
3885
+ git ls-files -o >out &&
3886
+ test_line_count = 4 out &&
3860
3887
3861
- git ls-files -s >out &&
3862
- test_line_count = 4 out &&
3863
- git ls-files -u >out &&
3864
- test_line_count = 1 out &&
3865
- git ls-files -o >out &&
3866
- test_line_count = 5 out &&
3888
+ git rev-parse >actual \
3889
+ :0:x/b :0:y/a :0:y/c/d :3:y/c &&
3890
+ git rev-parse >expect \
3891
+ O:x/b O:z/a B:y/c/d B:x/c &&
3892
+ test_cmp expect actual &&
3867
3893
3868
- git rev-parse >actual \
3869
- :0:x/b :0:y/a :0:y/c/d :3:y/c &&
3870
- git rev-parse >expect \
3871
- O:x/b O:z/a B:y/c/d B:x/c &&
3872
- test_cmp expect actual &&
3894
+ git hash-object y/c~HEAD >actual &&
3895
+ git rev-parse B:x/c >expect &&
3896
+ test_cmp expect actual
3897
+ fi &&
3873
3898
3874
- git hash-object y/c~HEAD >actual &&
3875
- git rev-parse B:x/c >expect &&
3876
- test_cmp expect actual
3899
+ grep -q stuff z/c &&
3900
+ test_seq 1 10 >expected &&
3901
+ echo stuff >>expected &&
3902
+ test_cmp expected z/c
3877
3903
)
3878
3904
'
3879
3905
@@ -3931,37 +3957,43 @@ test_expect_success '11e: Avoid deleting not-uptodate with dir rename/rename(1to
3931
3957
echo mods >>y/c &&
3932
3958
3933
3959
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3934
- test_i18ngrep "CONFLICT (rename/rename)" out &&
3935
- test_i18ngrep "Refusing to lose dirty file at y/c" out &&
3960
+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3961
+ then
3962
+ test_path_is_missing .git/MERGE_HEAD &&
3963
+ test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
3964
+ else
3965
+ test_i18ngrep "CONFLICT (rename/rename)" out &&
3966
+ test_i18ngrep "Refusing to lose dirty file at y/c" out &&
3936
3967
3937
- git ls-files -s >out &&
3938
- test_line_count = 7 out &&
3939
- git ls-files -u >out &&
3940
- test_line_count = 4 out &&
3941
- git ls-files -o >out &&
3942
- test_line_count = 3 out &&
3968
+ git ls-files -s >out &&
3969
+ test_line_count = 7 out &&
3970
+ git ls-files -u >out &&
3971
+ test_line_count = 4 out &&
3972
+ git ls-files -o >out &&
3973
+ test_line_count = 3 out &&
3974
+
3975
+ git rev-parse >actual \
3976
+ :0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :2:y/c :3:y/c &&
3977
+ git rev-parse >expect \
3978
+ O:z/a O:z/b O:x/d O:x/c O:x/c A:y/c O:x/c &&
3979
+ test_cmp expect actual &&
3980
+
3981
+ # See if y/c~merged has expected contents; requires manually
3982
+ # doing the expected file merge
3983
+ git cat-file -p A:y/c >c1 &&
3984
+ git cat-file -p B:z/c >c2 &&
3985
+ >empty &&
3986
+ test_must_fail git merge-file \
3987
+ -L "HEAD" \
3988
+ -L "" \
3989
+ -L "B^0" \
3990
+ c1 empty c2 &&
3991
+ test_cmp c1 y/c~merged
3992
+ fi &&
3943
3993
3944
3994
echo different >expected &&
3945
3995
echo mods >>expected &&
3946
- test_cmp expected y/c &&
3947
-
3948
- git rev-parse >actual \
3949
- :0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :2:y/c :3:y/c &&
3950
- git rev-parse >expect \
3951
- O:z/a O:z/b O:x/d O:x/c O:x/c A:y/c O:x/c &&
3952
- test_cmp expect actual &&
3953
-
3954
- # See if y/c~merged has expected contents; requires manually
3955
- # doing the expected file merge
3956
- git cat-file -p A:y/c >c1 &&
3957
- git cat-file -p B:z/c >c2 &&
3958
- >empty &&
3959
- test_must_fail git merge-file \
3960
- -L "HEAD" \
3961
- -L "" \
3962
- -L "B^0" \
3963
- c1 empty c2 &&
3964
- test_cmp c1 y/c~merged
3996
+ test_cmp expected y/c
3965
3997
)
3966
3998
'
3967
3999
@@ -4014,38 +4046,44 @@ test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to
4014
4046
echo important >>y/wham &&
4015
4047
4016
4048
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
4017
- test_i18ngrep "CONFLICT (rename/rename)" out &&
4018
- test_i18ngrep "Refusing to lose dirty file at y/wham" out &&
4049
+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
4050
+ then
4051
+ test_path_is_missing .git/MERGE_HEAD &&
4052
+ test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
4053
+ else
4054
+ test_i18ngrep "CONFLICT (rename/rename)" out &&
4055
+ test_i18ngrep "Refusing to lose dirty file at y/wham" out &&
4019
4056
4020
- git ls-files -s >out &&
4021
- test_line_count = 4 out &&
4022
- git ls-files -u >out &&
4023
- test_line_count = 2 out &&
4024
- git ls-files -o >out &&
4025
- test_line_count = 3 out &&
4057
+ git ls-files -s >out &&
4058
+ test_line_count = 4 out &&
4059
+ git ls-files -u >out &&
4060
+ test_line_count = 2 out &&
4061
+ git ls-files -o >out &&
4062
+ test_line_count = 3 out &&
4026
4063
4027
- test_seq 1 10 >expected &&
4028
- echo important >>expected &&
4029
- test_cmp expected y/wham &&
4064
+ test_must_fail git rev-parse :1:y/wham &&
4030
4065
4031
- test_must_fail git rev-parse :1:y/wham &&
4066
+ git rev-parse >actual \
4067
+ :0:y/a :0:y/b :2:y/wham :3:y/wham &&
4068
+ git rev-parse >expect \
4069
+ O:z/a O:z/b O:x/c O:x/d &&
4070
+ test_cmp expect actual &&
4032
4071
4033
- git rev-parse >actual \
4034
- :0:y/a :0:y/b :2:y/wham :3:y/wham &&
4035
- git rev-parse >expect \
4036
- O:z/a O:z/b O:x/c O:x/d &&
4037
- test_cmp expect actual &&
4072
+ # Test that two-way merge in y/wham~merged is as expected
4073
+ git cat-file -p :2:y/wham >expect &&
4074
+ git cat-file -p :3:y/wham >other &&
4075
+ >empty &&
4076
+ test_must_fail git merge-file \
4077
+ -L "HEAD" \
4078
+ -L "" \
4079
+ -L "B^0" \
4080
+ expect empty other &&
4081
+ test_cmp expect y/wham~merged
4082
+ fi &&
4038
4083
4039
- # Test that the two-way merge in y/wham~merged is as expected
4040
- git cat-file -p :2:y/wham >expect &&
4041
- git cat-file -p :3:y/wham >other &&
4042
- >empty &&
4043
- test_must_fail git merge-file \
4044
- -L "HEAD" \
4045
- -L "" \
4046
- -L "B^0" \
4047
- expect empty other &&
4048
- test_cmp expect y/wham~merged
4084
+ test_seq 1 10 >expected &&
4085
+ echo important >>expected &&
4086
+ test_cmp expected y/wham
4049
4087
)
4050
4088
'
4051
4089
0 commit comments