Skip to content

Commit 52241c9

Browse files
committed
Merge branch 'en/merge-process-renames-crash-fix'
The merge-recursive and merge-ort machinery crashed in corner cases when certain renames are involved. * en/merge-process-renames-crash-fix: merge-ort: fix slightly overzealous assertion for rename-to-self t6423: add a testcase causing a failed assertion in process_renames
2 parents 1a764cd + 3adba40 commit 52241c9

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5363,6 +5363,47 @@ test_expect_merge_algorithm failure success '12m: Change parent of renamed-dir t
53635363
)
53645364
'
53655365

5366+
test_setup_12n () {
5367+
git init 12n &&
5368+
(
5369+
cd 12n &&
5370+
5371+
mkdir tools &&
5372+
echo hello >tools/hello &&
5373+
git add tools/hello &&
5374+
git commit -m "O" &&
5375+
5376+
git branch O &&
5377+
git branch A &&
5378+
git branch B &&
5379+
5380+
git switch A &&
5381+
echo world >world &&
5382+
git add world &&
5383+
git commit -q world -m 'Add world' &&
5384+
5385+
git mv world tools/world &&
5386+
git commit -m "Move world into tools/" &&
5387+
5388+
git switch B &&
5389+
git mv tools/hello hello &&
5390+
git commit -m "Move hello from tools/ to toplevel"
5391+
)
5392+
}
5393+
5394+
test_expect_success '12n: Directory rename transitively makes rename back to self' '
5395+
test_setup_12n &&
5396+
(
5397+
cd 12n &&
5398+
5399+
git checkout -q B^0 &&
5400+
5401+
test_must_fail git cherry-pick A^0 >out &&
5402+
grep "CONFLICT (file location).*should perhaps be moved" out
5403+
)
5404+
'
5405+
5406+
53665407
###########################################################################
53675408
# SECTION 13: Checking informational and conflict messages
53685409
#

0 commit comments

Comments
 (0)