t6423, t6436: note improved ort handling with dirty files
The "recursive" backend relies on unpack_trees() to check if unstaged changes would be overwritten by a merge, but unpack_trees() does not understand renames -- and once it returns, it has already written many updates to the working tree and index. As such, "recursive" had to do a special 4-way merge where it would need to also treat the working copy as an extra source of differences that we had to carefully avoid overwriting and resulting in moving files to new locations to avoid conflicts. The "ort" backend, by contrast, does the complete merge inmemory, and only updates the index and working copy as a post-processing step. If there are dirty files in the way, it can simply abort the merge. Update t6423 and t6436 to reflect the better merge abilities and expectations we have for ort, while still leaving the best-case-as-good-as-recursive-can-do expectations there for the recursive backend so we retain its stability until we are ready to deprecate and remove it. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
c8c35f6a02
commit
23bef2e33c
@ -3634,18 +3634,19 @@ test_expect_success '11a: Avoid losing dirty contents with simple rename' '
|
|||||||
echo stuff >>z/c &&
|
echo stuff >>z/c &&
|
||||||
|
|
||||||
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
||||||
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
||||||
|
then
|
||||||
|
test_path_is_missing .git/MERGE_HEAD &&
|
||||||
|
test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
|
||||||
|
else
|
||||||
test_i18ngrep "Refusing to lose dirty file at z/c" out &&
|
test_i18ngrep "Refusing to lose dirty file at z/c" out &&
|
||||||
|
|
||||||
test_seq 1 10 >expected &&
|
|
||||||
echo stuff >>expected &&
|
|
||||||
test_cmp expected z/c &&
|
|
||||||
|
|
||||||
git ls-files -s >out &&
|
git ls-files -s >out &&
|
||||||
test_line_count = 2 out &&
|
test_line_count = 2 out &&
|
||||||
git ls-files -u >out &&
|
git ls-files -u >out &&
|
||||||
test_line_count = 1 out &&
|
test_line_count = 1 out &&
|
||||||
git ls-files -o >out &&
|
git ls-files -o >out &&
|
||||||
test_line_count = 4 out &&
|
test_line_count = 3 out &&
|
||||||
|
|
||||||
git rev-parse >actual \
|
git rev-parse >actual \
|
||||||
:0:z/a :2:z/c &&
|
:0:z/a :2:z/c &&
|
||||||
@ -3656,6 +3657,12 @@ test_expect_success '11a: Avoid losing dirty contents with simple rename' '
|
|||||||
git hash-object z/c~HEAD >actual &&
|
git hash-object z/c~HEAD >actual &&
|
||||||
git rev-parse B:z/b >expect &&
|
git rev-parse B:z/b >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
test_seq 1 10 >expected &&
|
||||||
|
echo stuff >>expected &&
|
||||||
|
test_cmp expected z/c
|
||||||
|
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -3706,14 +3713,15 @@ test_expect_success '11b: Avoid losing dirty file involved in directory rename'
|
|||||||
git checkout A^0 &&
|
git checkout A^0 &&
|
||||||
echo stuff >>z/c &&
|
echo stuff >>z/c &&
|
||||||
|
|
||||||
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
||||||
|
then
|
||||||
|
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
||||||
|
test_path_is_missing .git/MERGE_HEAD &&
|
||||||
|
test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
|
||||||
|
else
|
||||||
git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
||||||
test_i18ngrep "Refusing to lose dirty file at z/c" out &&
|
test_i18ngrep "Refusing to lose dirty file at z/c" out &&
|
||||||
|
|
||||||
grep -q stuff z/c &&
|
|
||||||
test_seq 1 10 >expected &&
|
|
||||||
echo stuff >>expected &&
|
|
||||||
test_cmp expected z/c &&
|
|
||||||
|
|
||||||
git ls-files -s >out &&
|
git ls-files -s >out &&
|
||||||
test_line_count = 3 out &&
|
test_line_count = 3 out &&
|
||||||
git ls-files -u >out &&
|
git ls-files -u >out &&
|
||||||
@ -3721,7 +3729,7 @@ test_expect_success '11b: Avoid losing dirty file involved in directory rename'
|
|||||||
git ls-files -m >out &&
|
git ls-files -m >out &&
|
||||||
test_line_count = 0 out &&
|
test_line_count = 0 out &&
|
||||||
git ls-files -o >out &&
|
git ls-files -o >out &&
|
||||||
test_line_count = 4 out &&
|
test_line_count = 3 out &&
|
||||||
|
|
||||||
git rev-parse >actual \
|
git rev-parse >actual \
|
||||||
:0:x/b :0:y/a :0:y/c &&
|
:0:x/b :0:y/a :0:y/c &&
|
||||||
@ -3732,6 +3740,12 @@ test_expect_success '11b: Avoid losing dirty file involved in directory rename'
|
|||||||
git hash-object y/c >actual &&
|
git hash-object y/c >actual &&
|
||||||
git rev-parse B:x/c >expect &&
|
git rev-parse B:x/c >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
grep -q stuff z/c &&
|
||||||
|
test_seq 1 10 >expected &&
|
||||||
|
echo stuff >>expected &&
|
||||||
|
test_cmp expected z/c
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -3783,7 +3797,13 @@ test_expect_success '11c: Avoid losing not-uptodate with rename + D/F conflict'
|
|||||||
echo stuff >>y/c &&
|
echo stuff >>y/c &&
|
||||||
|
|
||||||
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
||||||
test_i18ngrep "following files would be overwritten by merge" err &&
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
||||||
|
then
|
||||||
|
test_path_is_missing .git/MERGE_HEAD &&
|
||||||
|
test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
|
||||||
|
else
|
||||||
|
test_i18ngrep "following files would be overwritten by merge" err
|
||||||
|
fi &&
|
||||||
|
|
||||||
grep -q stuff y/c &&
|
grep -q stuff y/c &&
|
||||||
test_seq 1 10 >expected &&
|
test_seq 1 10 >expected &&
|
||||||
@ -3851,19 +3871,19 @@ test_expect_success '11d: Avoid losing not-uptodate with rename + D/F conflict'
|
|||||||
echo stuff >>z/c &&
|
echo stuff >>z/c &&
|
||||||
|
|
||||||
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
||||||
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
||||||
|
then
|
||||||
|
test_path_is_missing .git/MERGE_HEAD &&
|
||||||
|
test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
|
||||||
|
else
|
||||||
test_i18ngrep "Refusing to lose dirty file at z/c" out &&
|
test_i18ngrep "Refusing to lose dirty file at z/c" out &&
|
||||||
|
|
||||||
grep -q stuff z/c &&
|
|
||||||
test_seq 1 10 >expected &&
|
|
||||||
echo stuff >>expected &&
|
|
||||||
test_cmp expected z/c &&
|
|
||||||
|
|
||||||
git ls-files -s >out &&
|
git ls-files -s >out &&
|
||||||
test_line_count = 4 out &&
|
test_line_count = 4 out &&
|
||||||
git ls-files -u >out &&
|
git ls-files -u >out &&
|
||||||
test_line_count = 1 out &&
|
test_line_count = 1 out &&
|
||||||
git ls-files -o >out &&
|
git ls-files -o >out &&
|
||||||
test_line_count = 5 out &&
|
test_line_count = 4 out &&
|
||||||
|
|
||||||
git rev-parse >actual \
|
git rev-parse >actual \
|
||||||
:0:x/b :0:y/a :0:y/c/d :3:y/c &&
|
:0:x/b :0:y/a :0:y/c/d :3:y/c &&
|
||||||
@ -3874,6 +3894,12 @@ test_expect_success '11d: Avoid losing not-uptodate with rename + D/F conflict'
|
|||||||
git hash-object y/c~HEAD >actual &&
|
git hash-object y/c~HEAD >actual &&
|
||||||
git rev-parse B:x/c >expect &&
|
git rev-parse B:x/c >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
grep -q stuff z/c &&
|
||||||
|
test_seq 1 10 >expected &&
|
||||||
|
echo stuff >>expected &&
|
||||||
|
test_cmp expected z/c
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -3931,6 +3957,11 @@ test_expect_success '11e: Avoid deleting not-uptodate with dir rename/rename(1to
|
|||||||
echo mods >>y/c &&
|
echo mods >>y/c &&
|
||||||
|
|
||||||
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
||||||
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
||||||
|
then
|
||||||
|
test_path_is_missing .git/MERGE_HEAD &&
|
||||||
|
test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
|
||||||
|
else
|
||||||
test_i18ngrep "CONFLICT (rename/rename)" out &&
|
test_i18ngrep "CONFLICT (rename/rename)" out &&
|
||||||
test_i18ngrep "Refusing to lose dirty file at y/c" out &&
|
test_i18ngrep "Refusing to lose dirty file at y/c" out &&
|
||||||
|
|
||||||
@ -3941,10 +3972,6 @@ test_expect_success '11e: Avoid deleting not-uptodate with dir rename/rename(1to
|
|||||||
git ls-files -o >out &&
|
git ls-files -o >out &&
|
||||||
test_line_count = 3 out &&
|
test_line_count = 3 out &&
|
||||||
|
|
||||||
echo different >expected &&
|
|
||||||
echo mods >>expected &&
|
|
||||||
test_cmp expected y/c &&
|
|
||||||
|
|
||||||
git rev-parse >actual \
|
git rev-parse >actual \
|
||||||
:0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :2:y/c :3:y/c &&
|
:0:y/a :0:y/b :0:x/d :1:x/c :2:w/c :2:y/c :3:y/c &&
|
||||||
git rev-parse >expect \
|
git rev-parse >expect \
|
||||||
@ -3962,6 +3989,11 @@ test_expect_success '11e: Avoid deleting not-uptodate with dir rename/rename(1to
|
|||||||
-L "B^0" \
|
-L "B^0" \
|
||||||
c1 empty c2 &&
|
c1 empty c2 &&
|
||||||
test_cmp c1 y/c~merged
|
test_cmp c1 y/c~merged
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
echo different >expected &&
|
||||||
|
echo mods >>expected &&
|
||||||
|
test_cmp expected y/c
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -4014,6 +4046,11 @@ test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to
|
|||||||
echo important >>y/wham &&
|
echo important >>y/wham &&
|
||||||
|
|
||||||
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
|
||||||
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
||||||
|
then
|
||||||
|
test_path_is_missing .git/MERGE_HEAD &&
|
||||||
|
test_i18ngrep "error: Your local changes to the following files would be overwritten by merge" err
|
||||||
|
else
|
||||||
test_i18ngrep "CONFLICT (rename/rename)" out &&
|
test_i18ngrep "CONFLICT (rename/rename)" out &&
|
||||||
test_i18ngrep "Refusing to lose dirty file at y/wham" out &&
|
test_i18ngrep "Refusing to lose dirty file at y/wham" out &&
|
||||||
|
|
||||||
@ -4024,10 +4061,6 @@ test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to
|
|||||||
git ls-files -o >out &&
|
git ls-files -o >out &&
|
||||||
test_line_count = 3 out &&
|
test_line_count = 3 out &&
|
||||||
|
|
||||||
test_seq 1 10 >expected &&
|
|
||||||
echo important >>expected &&
|
|
||||||
test_cmp expected y/wham &&
|
|
||||||
|
|
||||||
test_must_fail git rev-parse :1:y/wham &&
|
test_must_fail git rev-parse :1:y/wham &&
|
||||||
|
|
||||||
git rev-parse >actual \
|
git rev-parse >actual \
|
||||||
@ -4036,7 +4069,7 @@ test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to
|
|||||||
O:z/a O:z/b O:x/c O:x/d &&
|
O:z/a O:z/b O:x/c O:x/d &&
|
||||||
test_cmp expect actual &&
|
test_cmp expect actual &&
|
||||||
|
|
||||||
# Test that the two-way merge in y/wham~merged is as expected
|
# Test that two-way merge in y/wham~merged is as expected
|
||||||
git cat-file -p :2:y/wham >expect &&
|
git cat-file -p :2:y/wham >expect &&
|
||||||
git cat-file -p :3:y/wham >other &&
|
git cat-file -p :3:y/wham >other &&
|
||||||
>empty &&
|
>empty &&
|
||||||
@ -4046,6 +4079,11 @@ test_expect_success '11f: Avoid deleting not-uptodate with dir rename/rename(2to
|
|||||||
-L "B^0" \
|
-L "B^0" \
|
||||||
expect empty other &&
|
expect empty other &&
|
||||||
test_cmp expect y/wham~merged
|
test_cmp expect y/wham~merged
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
test_seq 1 10 >expected &&
|
||||||
|
echo important >>expected &&
|
||||||
|
test_cmp expected y/wham
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -97,11 +97,19 @@ test_expect_success 'will not overwrite unstaged changes in renamed file' '
|
|||||||
git mv c1.c other.c &&
|
git mv c1.c other.c &&
|
||||||
git commit -m rename &&
|
git commit -m rename &&
|
||||||
cp important other.c &&
|
cp important other.c &&
|
||||||
|
if test "$GIT_TEST_MERGE_ALGORITHM" = ort
|
||||||
|
then
|
||||||
|
test_must_fail git merge c1a >out 2>err &&
|
||||||
|
test_i18ngrep "would be overwritten by merge" err &&
|
||||||
|
test_cmp important other.c &&
|
||||||
|
test_path_is_missing .git/MERGE_HEAD
|
||||||
|
else
|
||||||
test_must_fail git merge c1a >out &&
|
test_must_fail git merge c1a >out &&
|
||||||
test_i18ngrep "Refusing to lose dirty file at other.c" out &&
|
test_i18ngrep "Refusing to lose dirty file at other.c" out &&
|
||||||
test_path_is_file other.c~HEAD &&
|
test_path_is_file other.c~HEAD &&
|
||||||
test $(git hash-object other.c~HEAD) = $(git rev-parse c1a:c1.c) &&
|
test $(git hash-object other.c~HEAD) = $(git rev-parse c1a:c1.c) &&
|
||||||
test_cmp important other.c
|
test_cmp important other.c
|
||||||
|
fi
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'will not overwrite untracked subtree' '
|
test_expect_success 'will not overwrite untracked subtree' '
|
||||||
|
Loading…
Reference in New Issue
Block a user