From: Elijah Newren <newren@xxxxxxxxx> There is code in both merge-recursive and merge-ort for avoiding doubly transitive renames (i.e. one side renames directory A/ -> B/, and the other side renames directory B/ -> C/), because this combination would otherwise make a mess for new files added to A/ on the first side and wondering which directory they end up in -- especially if there were even more renames such as the first side renaming C/ -> D/. In such cases, it just turns "off" directory rename detection for the higher order transitive cases. The testcases added in t6423 a couple commits ago are slightly different but similar in principle. They involve a similar case of paired renaming but instead of A/ -> B/ and B/ -> C/, the second side renames a leading directory of B/ to C/. And both sides add a new file somewhere under the directory that the other side will rename. While the new files added start within different directories and thus could logically end up within different directories, it is weird for a file on one side to end up where the other one started and not move along with it. So, let's just turn off directory rename detection in this case as well. Signed-off-by: Elijah Newren <newren@xxxxxxxxx> --- merge-ort.c | 4 ++++ t/t6423-merge-rename-directories.sh | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/merge-ort.c b/merge-ort.c index fa6667de18c..5bcb9a4980b 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -2292,9 +2292,13 @@ static char *check_for_directory_rename(struct merge_options *opt, struct strmap_entry *rename_info; struct strmap_entry *otherinfo = NULL; const char *new_dir; + int other_side = 3 - side_index; + /* Cases where there is no new path, so we return NULL */ if (strmap_empty(dir_renames)) return new_path; + if (strmap_get(&collisions[other_side], path)) + return new_path; rename_info = check_dir_renamed(path, dir_renames); if (!rename_info) return new_path; diff --git a/t/t6423-merge-rename-directories.sh b/t/t6423-merge-rename-directories.sh index 296c04f8046..4286ae987c4 100755 --- a/t/t6423-merge-rename-directories.sh +++ b/t/t6423-merge-rename-directories.sh @@ -5245,7 +5245,7 @@ test_setup_12l () { ) } -test_expect_merge_algorithm failure failure '12l (B into A): Rename into each other + add/add conflict' ' +test_expect_merge_algorithm failure success '12l (B into A): Rename into each other + add/add conflict' ' test_setup_12l BintoA && ( cd 12l_BintoA && @@ -5273,7 +5273,7 @@ test_expect_merge_algorithm failure failure '12l (B into A): Rename into each ot ) ' -test_expect_merge_algorithm failure failure '12l (A into B): Rename into each other + add/add conflict' ' +test_expect_merge_algorithm failure success '12l (A into B): Rename into each other + add/add conflict' ' test_setup_12l AintoB && ( cd 12l_AintoB && -- gitgitgadget