t6423: test directory renames causing rename-to-self
commit806f83287f8d6c0568beed7ca5d603f936d53c40
authorElijah Newren <newren@gmail.com>
Wed, 30 Jun 2021 17:29:58 +0000 (30 17:29 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Jun 2021 21:40:09 +0000 (30 14:40 -0700)
tree6558a70ca35033d686b9bc79ed4920f7eba496ce
parentebf3c04b262aa27fbb97f8a0156c2347fecafafb
t6423: test directory renames causing rename-to-self

Directory rename detection can cause transitive renames, e.g. if the two
different sides of history each do one half of:
    A/file -> B/file
    B/     -> C/
then directory rename detection transitively renames to give us C/file.
Since the default for merge.directoryRenames is conflict, this results
in an error message saying it is unclear whether the file should be
placed at B/file or C/file.

What if C/ is A/, though?  In such a case, the transitive rename would
give us A/file, the original name we started with.  Logically, having
an error message with B/file vs. A/file should be fine, as should
leaving the file where it started.  But the logic in both
merge-recursive and merge-ort did not handle a case of a filename being
renamed to itself correctly; merge-recursive had two bugs, and merge-ort
had one.  Add some testcases covering such a scenario.

Based-on-testcase-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t6423-merge-rename-directories.sh