@@ -25,9 +25,79 @@ This edition covers what happened during the month of May 2022.
2525### Reviews
2626-->
2727
28- <!-- -
2928### Support
30- -->
29+
30+ * [ Bug in merge-ort (rename detection can have collisions?)
] ( https://public-inbox.org/git/[email protected] / ) 31+
32+ Glen Choo reported on the mailing list that ` git merge ` was failing
33+ on certain branches of a repo used at his workplace. As the repo is
34+ a public one, Glen could share the full recipe to reproduce the bug.
35+
36+ When following it one get the following error:
37+
38+ ` Assertion failed: (ci->filemask == 2 || ci->filemask == 4), function apply_directory_rename_modifications, file merge-ort.c, line 2410. `
39+
40+ Glen noticed that the bug seemed specific to the "ort" merge
41+ strategy, which recently became the default merge strategy, as when
42+ using the "recursive"strategy, which used to be the default merge
43+ strategy before "ort" took over, the merge seemed to work as
44+ expected.
45+
46+ Glen also tried to debug the issue by himself and found that the
47+ reason for the assertion failure seemed to be that two files
48+ involved in the merge were renames of each other.
49+
50+ Elijah Newren, who developed the new "ort" strategy, thanked Glen
51+ for the detailed report, and said that he found a small reproduction
52+ recipe to simplify what's going on. He explained it with the
53+ following:
54+
55+ ```
56+ # Commit O: sub1/file, sub2/other
57+ # Commit A: sub3/file, sub2/{other, new_add_add_file_1}
58+ # Commit B: sub1/{file, newfile}, sub1/sub2/{other, new_add_add_file_2}
59+ #
60+ # In words:
61+ # A: sub1/ -> sub3/, add sub2/new_add_add_file_1
62+ # B: sub2/ -> sub1/sub2, add sub1/newfile, add sub1/sub2/new_add_add_file_2
63+ ```
64+
65+ He then explained that both the "ort" and "recursive" merge
66+ strategies have code to avoid "doubly transitive renames". Such
67+ renames happen when, for example, on one side of the merge a
68+ directory named "A" is renamed to "B", while on the other side "B"
69+ is renamed "C".
70+
71+ The code to avoid "doubly transitive renames" is fooled when a
72+ leading directory of a directory is renamed though. For example if
73+ on one side a directory named "A" is renamed to "B", while on the
74+ other side a leading directory of "B" is renamed to "C". That's what
75+ triggers the bug.
76+
77+ Junio Hamano, the Git maintainer, thanked Elijah for his continued
78+ support of the merge strategy, and noticed that at least the code is
79+ not "making a silent mismerge" in this special case and the
80+ recursive strategy is working.
81+
82+ Elijah replied that he was glad the recursive strategy worked for
83+ Glen because it didn't work either with his minimal reproduction
84+ test case.
85+
86+ Glen then wondered if turning off rename detection could help in
87+ case of merges with complex renames like this, but Elijah suggested
88+ using the 'resolve' strategy, which "is roughly the recursive
89+ strategy minus the renames and the multiple merge base handling",
90+ instead.
91+
92+ Elijah also posted
93+ [ a small patch series
] ( https://lore.kernel.org/git/[email protected] / ) 94+ that adds test cases demonstrating the bug Glen found and fixing it
95+ in the ort strategy code.
96+
97+ Jonathan Tan reviewed the series and verified that it indeed fixes
98+ Glen's test cases. Calvin Wan also commented on the patch series. So
99+ there is good hope that after a few iteration to polish the series
100+ the bug will be fixed soon.
31101
32102<!-- -
33103## Developer Spotlight:
0 commit comments