Skip to content

Commit 727c75b

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 489c85f commit 727c75b

File tree

2 files changed

+62
-22
lines changed

2 files changed

+62
-22
lines changed

t/t6404-recursive-merge.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,22 @@ test_expect_success 'mark rename/delete as unmerged' '
118118
test_tick &&
119119
git commit -m rename &&
120120
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 &&
122127
git rev-parse --verify :2:a2 &&
123128
test_must_fail git rev-parse --verify :3:a2 &&
124129
git checkout -f delete &&
125130
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 &&
127137
test_must_fail git rev-parse --verify :2:a2 &&
128138
git rev-parse --verify :3:a2
129139
'

t/t6423-merge-rename-directories.sh

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,17 +1271,32 @@ test_expect_success '6a: Tricky rename/delete' '
12711271
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out &&
12721272
test_i18ngrep "CONFLICT (rename/delete).*z/c.*y/c" out &&
12731273
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 &&
12801282
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 &&
12851300
test_cmp expect actual
12861301
)
12871302
'
@@ -1934,17 +1949,32 @@ test_expect_success '7d: transitive rename involved in rename/delete; how is it
19341949
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 >out &&
19351950
test_i18ngrep "CONFLICT (rename/delete).*x/d.*y/d" out &&
19361951
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 &&
19431960
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 &&
19481978
test_cmp expect actual
19491979
)
19501980
'

0 commit comments

Comments
 (0)