Skip to content

Commit 3adba40

Browse files
newrengitster
authored andcommitted
merge-ort: fix slightly overzealous assertion for rename-to-self
merge-ort has a number of sanity checks on the file it is processing in process_renames(). One of these sanity checks was slightly overzealous because it indirectly assumed that a renamed file always ended up at a different path than where it started. That is normally an entirely fair assumption, but directory rename detection can make things interesting. As a quick refresher, if one side of history renames directory A/ -> B/, and the other side of history adds new files to A/, then directory rename detection notices and suggests moving those new files to B/. A similar thing is done for paths renamed into A/, causing them to be transitively renamed into B/. But, if the file originally came from B/, then this can end up causing a file to be renamed back to itself. It turns out the rest of the code following this assertion handled the case fine; the assertion was just an extra sanity check, not a rigid precondition. Therefore, simply adjust the assertion to pass under this special case as well. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 98a1a00 commit 3adba40

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

merge-ort.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,8 @@ static int process_renames(struct merge_options *opt,
30483048
}
30493049
}
30503050

3051-
assert(source_deleted || oldinfo->filemask & old_sidemask);
3051+
assert(source_deleted || oldinfo->filemask & old_sidemask ||
3052+
!strcmp(pair->one->path, pair->two->path));
30523053

30533054
/* Need to check for special types of rename conflicts... */
30543055
if (collision && !source_deleted) {

t/t6423-merge-rename-directories.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5391,7 +5391,7 @@ test_setup_12n () {
53915391
)
53925392
}
53935393

5394-
test_expect_failure '12n: Directory rename transitively makes rename back to self' '
5394+
test_expect_success '12n: Directory rename transitively makes rename back to self' '
53955395
test_setup_12n &&
53965396
(
53975397
cd 12n &&

0 commit comments

Comments
 (0)