Skip to content

Commit 0565cee

Browse files
newrengitster
authored andcommitted
t6423: add tests of dual directory rename plus add/add conflict
This is an attempt at minimalizing a testcase reported by Glen Choo with tensorflow where merge-ort would report an assertion failure: Assertion failed: (ci->filemask == 2 || ci->filemask == 4), function apply_directory_rename_modifications, file merge-ort.c, line 2410 reversing the direction of the merge provides a different error: error: cache entry has null sha1: ... fatal: unable to write .git/index so we add testcases for both. With these new testcases, the recursive strategy differs in that it returns the latter error for both merge directions. These testcases are somehow a little different than Glen's original tensorflow testcase in that these ones trigger a bug with the recursive algorithm whereas his testcase didn't. I figure that means these testcases somehow manage to be more comprehensive. Reported-by: Glen Choo <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dc8c8de commit 0565cee

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

t/t6423-merge-rename-directories.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5199,6 +5199,111 @@ test_expect_success '12k: Directory rename with sibling causes rename-to-self' '
51995199
)
52005200
'
52015201

5202+
# Testcase 12l, Both sides rename a directory into the other side, both add
5203+
# a file which after directory renames are the same filename
5204+
# Commit O: sub1/file, sub2/other
5205+
# Commit A: sub3/file, sub2/{other, new_add_add_file_1}
5206+
# Commit B: sub1/{file, newfile}, sub1/sub2/{other, new_add_add_file_2}
5207+
#
5208+
# In words:
5209+
# A: sub1/ -> sub3/, add sub2/new_add_add_file_1
5210+
# B: sub2/ -> sub1/sub2, add sub1/newfile, add sub1/sub2/new_add_add_file_2
5211+
#
5212+
# Expected: sub3/{file, newfile, sub2/other}
5213+
# CONFLICT (add/add): sub1/sub2/new_add_add_file
5214+
#
5215+
# Note that sub1/newfile is not extraneous. Directory renames are only
5216+
# detected if they are needed, and they are only needed if the old directory
5217+
# had a new file added on the opposite side of history. So sub1/newfile
5218+
# is needed for there to be a sub1/ -> sub3/ rename.
5219+
5220+
test_setup_12l () {
5221+
test_create_repo 12l_$1 &&
5222+
(
5223+
cd 12l_$1 &&
5224+
5225+
mkdir sub1 sub2
5226+
echo file >sub1/file &&
5227+
echo other >sub2/other &&
5228+
git add sub1 sub2 &&
5229+
git commit -m "O" &&
5230+
5231+
git branch O &&
5232+
git branch A &&
5233+
git branch B &&
5234+
5235+
git checkout A &&
5236+
git mv sub1 sub3 &&
5237+
echo conflicting >sub2/new_add_add_file &&
5238+
git add sub2 &&
5239+
test_tick &&
5240+
git add -u &&
5241+
git commit -m "A" &&
5242+
5243+
git checkout B &&
5244+
echo dissimilar >sub2/new_add_add_file &&
5245+
echo brand >sub1/newfile &&
5246+
git add sub1 sub2 &&
5247+
git mv sub2 sub1 &&
5248+
test_tick &&
5249+
git commit -m "B"
5250+
)
5251+
}
5252+
5253+
test_expect_merge_algorithm failure failure '12l (B into A): Rename into each other + add/add conflict' '
5254+
test_setup_12l BintoA &&
5255+
(
5256+
cd 12l_BintoA &&
5257+
5258+
git checkout -q A^0 &&
5259+
5260+
test_must_fail git -c merge.directoryRenames=true merge -s recursive B^0 &&
5261+
5262+
test_stdout_line_count = 5 git ls-files -s &&
5263+
5264+
git rev-parse >actual \
5265+
:0:sub3/file :0:sub3/newfile :0:sub3/sub2/other \
5266+
:2:sub1/sub2/new_add_add_file \
5267+
:3:sub1/sub2/new_add_add_file &&
5268+
git rev-parse >expect \
5269+
O:sub1/file B:sub1/newfile O:sub2/other \
5270+
A:sub2/new_add_add_file \
5271+
B:sub1/sub2/new_add_add_file &&
5272+
test_cmp expect actual &&
5273+
5274+
git ls-files -o >actual &&
5275+
test_write_lines actual expect >expect &&
5276+
test_cmp expect actual
5277+
)
5278+
'
5279+
5280+
test_expect_merge_algorithm failure failure '12l (A into B): Rename into each other + add/add conflict' '
5281+
test_setup_12l AintoB &&
5282+
(
5283+
cd 12l_AintoB &&
5284+
5285+
git checkout -q B^0 &&
5286+
5287+
test_must_fail git -c merge.directoryRenames=true merge -s recursive A^0 &&
5288+
5289+
test_stdout_line_count = 5 git ls-files -s &&
5290+
5291+
git rev-parse >actual \
5292+
:0:sub3/file :0:sub3/newfile :0:sub3/sub2/other \
5293+
:2:sub1/sub2/new_add_add_file \
5294+
:3:sub1/sub2/new_add_add_file &&
5295+
git rev-parse >expect \
5296+
O:sub1/file B:sub1/newfile O:sub2/other \
5297+
B:sub1/sub2/new_add_add_file \
5298+
A:sub2/new_add_add_file &&
5299+
test_cmp expect actual &&
5300+
5301+
git ls-files -o >actual &&
5302+
test_write_lines actual expect >expect &&
5303+
test_cmp expect actual
5304+
)
5305+
'
5306+
52025307
###########################################################################
52035308
# SECTION 13: Checking informational and conflict messages
52045309
#

0 commit comments

Comments
 (0)