Anders Kaseorg recently reported a few issues in an interesting rename case[1]. I was able to duplicate and find multiple bugs from it; two in merge-recursive, and one in merge-ort. This series has some fixes. Changes since v1: * Added a third testcase [1] https://lore.kernel.org/git/CABPp-BGDfucqae=HNES_QmmsjpDbdHrR6CG=H3gtiDygHzquVg@xxxxxxxxxxxxxx/ Elijah Newren (3): t6423: test directory renames causing rename-to-self merge-ort: ensure we consult df_conflict and path_conflicts merge-recursive: handle rename-to-self case merge-ort.c | 6 +- merge-recursive.c | 19 ++- t/t6423-merge-rename-directories.sh | 175 ++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+), 7 deletions(-) base-commit: 670b81a890388c60b7032a4f5b879f2ece8c4558 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1039%2Fnewren%2Frename-plus-dir-rename-cancel-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1039/newren/rename-plus-dir-rename-cancel-v2 Pull-Request: https://github.com/git/git/pull/1039 Range-diff vs v1: 1: d3572e8bc85 ! 1: 86b2eaea75e t6423: test directory renames causing rename-to-self @@ t/t6423-merge-rename-directories.sh: test_expect_failure '12h: renaming a file w + test_cmp expect actual + ) +' ++ ++# Testcase 12k, Directory rename with sibling causes rename-to-self ++# Commit O: dirB/foo, dirA/{bar, baz_1} ++# Commit A: dirA/{foo, bar, baz_1} ++# Commit B: dirB/{foo, bar}, dirA/baz_2 ++# Expected: dirA/{foo, bar, baz_2}, with conflicts on dirA/bar vs. dirB/bar ++ ++test_setup_12k () { ++ test_create_repo 12k && ++ ( ++ cd 12k && ++ ++ mkdir dirA dirB && ++ echo foo >dirB/foo && ++ echo bar >dirA/bar && ++ echo baz >dirA/baz && ++ git add . && ++ git commit -m orig && ++ ++ git branch O && ++ git branch A && ++ git branch B && ++ ++ git switch A && ++ git mv dirB/* dirA/ && ++ git commit -m A && ++ ++ git switch B && ++ git mv dirA/bar dirB/bar && ++ echo more baz >>dirA/baz && ++ git commit -m B ++ ) ++} ++ ++test_expect_merge_algorithm failure failure '12k: Directory rename with sibling causes rename-to-self' ' ++ test_setup_12k && ++ ( ++ cd 12k && ++ ++ git checkout A^0 && ++ ++ test_must_fail git -c merge.directoryRenames=conflict merge -s recursive B^0 && ++ ++ test_path_is_missing dirB && ++ test_path_is_file dirA/bar && ++ test_path_is_file dirA/baz && ++ ++ git ls-files | uniq >tracked && ++ test_line_count = 3 tracked && ++ ++ git status --porcelain -uno >actual && ++ cat >expect <<-\EOF && ++ UU dirA/bar ++ M dirA/baz ++ EOF ++ test_cmp expect actual ++ ) ++' + ########################################################################### # SECTION 13: Checking informational and conflict messages 2: 052f40c3c1a ! 2: 6e7ef18bf53 merge-ort: ensure we consult df_conflict and path_conflicts @@ t/t6423-merge-rename-directories.sh: test_setup_12j () { test_setup_12j && ( cd 12j && +@@ t/t6423-merge-rename-directories.sh: test_setup_12k () { + ) + } + +-test_expect_merge_algorithm failure failure '12k: Directory rename with sibling causes rename-to-self' ' ++test_expect_merge_algorithm failure success '12k: Directory rename with sibling causes rename-to-self' ' + test_setup_12k && + ( + cd 12k && 3: dea97c25e52 ! 3: 7c96d6c7a0a merge-recursive: handle rename-to-self case @@ t/t6423-merge-rename-directories.sh: test_setup_12j () { test_setup_12j && ( cd 12j && +@@ t/t6423-merge-rename-directories.sh: test_setup_12k () { + ) + } + +-test_expect_merge_algorithm failure success '12k: Directory rename with sibling causes rename-to-self' ' ++test_expect_success '12k: Directory rename with sibling causes rename-to-self' ' + test_setup_12k && + ( + cd 12k && -- gitgitgadget