@@ -3214,6 +3214,7 @@ test_expect_success '10a: Overwrite untracked with normal rename/delete' '
32143214 echo important >z/d &&
32153215
32163216 test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3217+ test_path_is_missing .git/MERGE_HEAD &&
32173218 test_i18ngrep "The following untracked working tree files would be overwritten by merge" err &&
32183219
32193220 git ls-files -s >out &&
@@ -3283,21 +3284,34 @@ test_expect_success '10b: Overwrite untracked with dir rename + delete' '
32833284 echo contents >y/e &&
32843285
32853286 test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3286- test_i18ngrep "CONFLICT (rename/delete).*Version B\^0 of y/d left in tree at y/d~B\^0" out &&
3287- test_i18ngrep "Error: Refusing to lose untracked file at y/e; writing to y/e~B\^0 instead" out &&
3287+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3288+ then
3289+ test_path_is_missing .git/MERGE_HEAD &&
3290+ test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err &&
32883291
3289- git ls-files -s >out &&
3290- test_line_count = 3 out &&
3291- git ls-files -u >out &&
3292- test_line_count = 2 out &&
3293- git ls-files -o >out &&
3294- test_line_count = 5 out &&
3292+ git ls-files -s >out &&
3293+ test_line_count = 1 out &&
3294+ git ls-files -u >out &&
3295+ test_line_count = 0 out &&
3296+ git ls-files -o >out &&
3297+ test_line_count = 5 out
3298+ else
3299+ test_i18ngrep "CONFLICT (rename/delete).*Version B\^0 of y/d left in tree at y/d~B\^0" out &&
3300+ test_i18ngrep "Error: Refusing to lose untracked file at y/e; writing to y/e~B\^0 instead" out &&
32953301
3296- git rev-parse >actual \
3297- :0:y/b :3:y/d :3:y/e &&
3298- git rev-parse >expect \
3299- O:z/b O:z/c B:z/e &&
3300- test_cmp expect actual &&
3302+ git ls-files -s >out &&
3303+ test_line_count = 3 out &&
3304+ git ls-files -u >out &&
3305+ test_line_count = 2 out &&
3306+ git ls-files -o >out &&
3307+ test_line_count = 5 out &&
3308+
3309+ git rev-parse >actual \
3310+ :0:y/b :3:y/d :3:y/e &&
3311+ git rev-parse >expect \
3312+ O:z/b O:z/c B:z/e &&
3313+ test_cmp expect actual
3314+ fi &&
33013315
33023316 echo very >expect &&
33033317 test_cmp expect y/c &&
@@ -3360,25 +3374,38 @@ test_expect_success '10c1: Overwrite untracked with dir rename/rename(1to2)' '
33603374 echo important >y/c &&
33613375
33623376 test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3363- test_i18ngrep "CONFLICT (rename/rename)" out &&
3364- test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~B\^0 instead" out &&
3377+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3378+ then
3379+ test_path_is_missing .git/MERGE_HEAD &&
3380+ test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err &&
33653381
3366- git ls-files -s >out &&
3367- test_line_count = 6 out &&
3368- git ls-files -u >out &&
3369- test_line_count = 3 out &&
3370- git ls-files -o >out &&
3371- test_line_count = 3 out &&
3382+ git ls-files -s >out &&
3383+ test_line_count = 4 out &&
3384+ git ls-files -u >out &&
3385+ test_line_count = 0 out &&
3386+ git ls-files -o >out &&
3387+ test_line_count = 3 out
3388+ else
3389+ test_i18ngrep "CONFLICT (rename/rename)" out &&
3390+ test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~B\^0 instead" out &&
33723391
3373- git rev-parse >actual \
3374- :0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :3:y/c &&
3375- git rev-parse >expect \
3376- O:z/a O:z/b O:x/d O:x/c O:x/c O:x/c &&
3377- test_cmp expect actual &&
3392+ git ls-files -s >out &&
3393+ test_line_count = 6 out &&
3394+ git ls-files -u >out &&
3395+ test_line_count = 3 out &&
3396+ git ls-files -o >out &&
3397+ test_line_count = 3 out &&
33783398
3379- git hash-object y/c~B^0 >actual &&
3380- git rev-parse O:x/c >expect &&
3381- test_cmp expect actual &&
3399+ git rev-parse >actual \
3400+ :0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :3:y/c &&
3401+ git rev-parse >expect \
3402+ O:z/a O:z/b O:x/d O:x/c O:x/c O:x/c &&
3403+ test_cmp expect actual &&
3404+
3405+ git hash-object y/c~B^0 >actual &&
3406+ git rev-parse O:x/c >expect &&
3407+ test_cmp expect actual
3408+ fi &&
33823409
33833410 echo important >expect &&
33843411 test_cmp expect y/c
@@ -3398,25 +3425,38 @@ test_expect_success '10c2: Overwrite untracked with dir rename/rename(1to2), oth
33983425 echo important >y/c &&
33993426
34003427 test_must_fail git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err &&
3401- test_i18ngrep "CONFLICT (rename/rename)" out &&
3402- test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~HEAD instead" out &&
3428+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3429+ then
3430+ test_path_is_missing .git/MERGE_HEAD &&
3431+ test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err &&
34033432
3404- git ls-files -s >out &&
3405- test_line_count = 6 out &&
3406- git ls-files -u >out &&
3407- test_line_count = 3 out &&
3408- git ls-files -o >out &&
3409- test_line_count = 3 out &&
3433+ git ls-files -s >out &&
3434+ test_line_count = 4 out &&
3435+ git ls-files -u >out &&
3436+ test_line_count = 0 out &&
3437+ git ls-files -o >out &&
3438+ test_line_count = 3 out
3439+ else
3440+ test_i18ngrep "CONFLICT (rename/rename)" out &&
3441+ test_i18ngrep "Refusing to lose untracked file at y/c; adding as y/c~HEAD instead" out &&
34103442
3411- git rev-parse >actual \
3412- :0:y/a :0:y/b :0:x/d :1:x/c :3:w/c :2:y/c &&
3413- git rev-parse >expect \
3414- O:z/a O:z/b O:x/d O:x/c O:x/c O:x/c &&
3415- test_cmp expect actual &&
3443+ git ls-files -s >out &&
3444+ test_line_count = 6 out &&
3445+ git ls-files -u >out &&
3446+ test_line_count = 3 out &&
3447+ git ls-files -o >out &&
3448+ test_line_count = 3 out &&
34163449
3417- git hash-object y/c~HEAD >actual &&
3418- git rev-parse O:x/c >expect &&
3419- test_cmp expect actual &&
3450+ git rev-parse >actual \
3451+ :0:y/a :0:y/b :0:x/d :1:x/c :3:w/c :2:y/c &&
3452+ git rev-parse >expect \
3453+ O:z/a O:z/b O:x/d O:x/c O:x/c O:x/c &&
3454+ test_cmp expect actual &&
3455+
3456+ git hash-object y/c~HEAD >actual &&
3457+ git rev-parse O:x/c >expect &&
3458+ test_cmp expect actual
3459+ fi &&
34203460
34213461 echo important >expect &&
34223462 test_cmp expect y/c
@@ -3474,37 +3514,50 @@ test_expect_success '10d: Delete untracked with dir rename/rename(2to1)' '
34743514 echo important >y/wham &&
34753515
34763516 test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
3477- test_i18ngrep "CONFLICT (rename/rename)" out &&
3478- test_i18ngrep "Refusing to lose untracked file at y/wham" out &&
3517+ if test "$GIT_TEST_MERGE_ALGORITHM" = ort
3518+ then
3519+ test_path_is_missing .git/MERGE_HEAD &&
3520+ test_i18ngrep "error: The following untracked working tree files would be overwritten by merge" err &&
34793521
3480- git ls-files -s >out &&
3481- test_line_count = 6 out &&
3482- git ls-files -u >out &&
3483- test_line_count = 2 out &&
3484- git ls-files -o >out &&
3485- test_line_count = 3 out &&
3522+ git ls-files -s >out &&
3523+ test_line_count = 6 out &&
3524+ git ls-files -u >out &&
3525+ test_line_count = 0 out &&
3526+ git ls-files -o >out &&
3527+ test_line_count = 3 out
3528+ else
3529+ test_i18ngrep "CONFLICT (rename/rename)" out &&
3530+ test_i18ngrep "Refusing to lose untracked file at y/wham" out &&
34863531
3487- git rev-parse >actual \
3488- :0:y/a :0:y/b :0:y/d :0:y/e :2:y/wham :3:y/wham &&
3489- git rev-parse >expect \
3490- O:z/a O:z/b O:x/d O:x/e O:z/c O:x/f &&
3491- test_cmp expect actual &&
3532+ git ls-files -s >out &&
3533+ test_line_count = 6 out &&
3534+ git ls-files -u >out &&
3535+ test_line_count = 2 out &&
3536+ git ls-files -o >out &&
3537+ test_line_count = 3 out &&
3538+
3539+ git rev-parse >actual \
3540+ :0:y/a :0:y/b :0:y/d :0:y/e :2:y/wham :3:y/wham &&
3541+ git rev-parse >expect \
3542+ O:z/a O:z/b O:x/d O:x/e O:z/c O:x/f &&
3543+ test_cmp expect actual &&
34923544
3493- test_must_fail git rev-parse :1:y/wham &&
3545+ test_must_fail git rev-parse :1:y/wham &&
34943546
3495- echo important >expect &&
3496- test_cmp expect y/wham &&
3547+ # Test that two-way merge in y/wham~merged is as expected
3548+ git cat-file -p :2:y/wham >expect &&
3549+ git cat-file -p :3:y/wham >other &&
3550+ >empty &&
3551+ test_must_fail git merge-file \
3552+ -L "HEAD" \
3553+ -L "" \
3554+ -L "B^0" \
3555+ expect empty other &&
3556+ test_cmp expect y/wham~merged
3557+ fi &&
34973558
3498- # Test that the two-way merge in y/wham~merged is as expected
3499- git cat-file -p :2:y/wham >expect &&
3500- git cat-file -p :3:y/wham >other &&
3501- >empty &&
3502- test_must_fail git merge-file \
3503- -L "HEAD" \
3504- -L "" \
3505- -L "B^0" \
3506- expect empty other &&
3507- test_cmp expect y/wham~merged
3559+ echo important >expect &&
3560+ test_cmp expect y/wham
35083561 )
35093562'
35103563
0 commit comments