t6404, t6423: expect improved rename/delete handling in ort backend

When a file is renamed and has content conflicts, merge-recursive does not have some stages for the old filename and some stages for the new filename in the index; instead it copies all the stages corresponding to the old filename over to the corresponding locations for the new filename, so that there are three higher order stages all corresponding to the new filename. Doing things this way makes it easier for the user to access the different versions and to resolve the conflict (no need to manually 'git rm' the old version as well as 'git add' the new one). rename/deletes should be handled similarly -- there should be two stages for the renamed file rather than just one. We do not want to destabilize merge-recursive right now, so instead update relevant tests to have different expectations depending on whether the "recursive" or "ort" merge strategies are in use. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Oct 26, 2020 at 17:01 UTC 727c75b23f25f752810f412e936d420f5c7fee04
2 files changed +62 -22
t/t6404-recursive-merge.sh
+12 -2
@@ -118,12 +118,22 @@ test_expect_success 'mark rename/delete as unmerged' '
118 test_tick &&
119 git commit -m rename &&
120 test_must_fail git merge delete &&
121 - test 1 = $(git ls-files --unmerged | wc -l) &&
121 + if test "$GIT_TEST_MERGE_ALGORITHM" = ort
122 + then
123 + test 2 = $(git ls-files --unmerged | wc -l)
124 + else
125 + test 1 = $(git ls-files --unmerged | wc -l)
126 + fi &&
127 git rev-parse --verify :2:a2 &&
128 test_must_fail git rev-parse --verify :3:a2 &&
129 git checkout -f delete &&
130 test_must_fail git merge rename &&
126 - test 1 = $(git ls-files --unmerged | wc -l) &&
131 + if test "$GIT_TEST_MERGE_ALGORITHM" = ort
132 + then
133 + test 2 = $(git ls-files --unmerged | wc -l)
134 + else
135 + test 1 = $(git ls-files --unmerged | wc -l)
136 + fi &&
137 test_must_fail git rev-parse --verify :2:a2 &&
138 git rev-parse --verify :3:a2
139 '
t/t6423-merge-rename-directories.sh
+50 -20
@@ -1271,17 +1271,32 @@ test_expect_success '6a: Tricky rename/delete' '
1271 test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out &&
1272 test_i18ngrep "CONFLICT (rename/delete).*z/c.*y/c" out &&
1273
1274 - git ls-files -s >out &&
1275 - test_line_count = 2 out &&
1276 - git ls-files -u >out &&
1277 - test_line_count = 1 out &&
1278 - git ls-files -o >out &&
1279 - test_line_count = 1 out &&
1274 + if test "$GIT_TEST_MERGE_ALGORITHM" = ort
1275 + then
1276 + git ls-files -s >out &&
1277 + test_line_count = 3 out &&
1278 + git ls-files -u >out &&
1279 + test_line_count = 2 out &&
1280 + git ls-files -o >out &&
1281 + test_line_count = 1 out &&
1282
1281 - git rev-parse >actual \
1282 - :0:y/b :3:y/c &&
1283 - git rev-parse >expect \
1284 - O:z/b O:z/c &&
1283 + git rev-parse >actual \
1284 + :0:y/b :1:y/c :3:y/c &&
1285 + git rev-parse >expect \
1286 + O:z/b O:z/c O:z/c
1287 + else
1288 + git ls-files -s >out &&
1289 + test_line_count = 2 out &&
1290 + git ls-files -u >out &&
1291 + test_line_count = 1 out &&
1292 + git ls-files -o >out &&
1293 + test_line_count = 1 out &&
1294 +
1295 + git rev-parse >actual \
1296 + :0:y/b :3:y/c &&
1297 + git rev-parse >expect \
1298 + O:z/b O:z/c
1299 + fi &&
1300 test_cmp expect actual
1301 )
1302 '
@@ -1934,17 +1949,32 @@ test_expect_success '7d: transitive rename involved in rename/delete; how is it
1949 test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out &&
1950 test_i18ngrep "CONFLICT (rename/delete).*x/d.*y/d" out &&
1951
1937 - git ls-files -s >out &&
1938 - test_line_count = 3 out &&
1939 - git ls-files -u >out &&
1940 - test_line_count = 1 out &&
1941 - git ls-files -o >out &&
1942 - test_line_count = 1 out &&
1952 + if test "$GIT_TEST_MERGE_ALGORITHM" = ort
1953 + then
1954 + git ls-files -s >out &&
1955 + test_line_count = 4 out &&
1956 + git ls-files -u >out &&
1957 + test_line_count = 2 out &&
1958 + git ls-files -o >out &&
1959 + test_line_count = 1 out &&
1960
1944 - git rev-parse >actual \
1945 - :0:y/b :0:y/c :3:y/d &&
1946 - git rev-parse >expect \
1947 - O:z/b O:z/c O:x/d &&
1961 + git rev-parse >actual \
1962 + :0:y/b :0:y/c :1:y/d :3:y/d &&
1963 + git rev-parse >expect \
1964 + O:z/b O:z/c O:x/d O:x/d
1965 + else
1966 + git ls-files -s >out &&
1967 + test_line_count = 3 out &&
1968 + git ls-files -u >out &&
1969 + test_line_count = 1 out &&
1970 + git ls-files -o >out &&
1971 + test_line_count = 1 out &&
1972 +
1973 + git rev-parse >actual \
1974 + :0:y/b :0:y/c :3:y/d &&
1975 + git rev-parse >expect \
1976 + O:z/b O:z/c O:x/d
1977 + fi &&
1978 test_cmp expect actual
1979 )
1980 '