mirror of
https://github.com/git/git
synced 2024-08-24 18:26:02 +00:00
Merge branch 'jz/apply-3-corner-cases'
"git apply --3way" bypasses the attempt to do a three-way application in more cases to address the regression caused by the recent change to use direct application as a fallback. * jz/apply-3-corner-cases: git-apply: skip threeway in add / rename cases
This commit is contained in:
commit
bc61dbac77
4
apply.c
4
apply.c
|
@ -3582,7 +3582,9 @@ static int try_threeway(struct apply_state *state,
|
||||||
|
|
||||||
/* No point falling back to 3-way merge in these cases */
|
/* No point falling back to 3-way merge in these cases */
|
||||||
if (patch->is_delete ||
|
if (patch->is_delete ||
|
||||||
S_ISGITLINK(patch->old_mode) || S_ISGITLINK(patch->new_mode))
|
S_ISGITLINK(patch->old_mode) || S_ISGITLINK(patch->new_mode) ||
|
||||||
|
(patch->is_new && !patch->direct_to_threeway) ||
|
||||||
|
(patch->is_rename && !patch->lines_added && !patch->lines_deleted))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Preimage the patch was prepared for */
|
/* Preimage the patch was prepared for */
|
||||||
|
|
|
@ -275,4 +275,22 @@ test_expect_success 'apply full-index patch with 3way' '
|
||||||
git apply --3way --index bin.diff
|
git apply --3way --index bin.diff
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'apply delete then new patch with 3way' '
|
||||||
|
git reset --hard main &&
|
||||||
|
test_write_lines 2 > delnew &&
|
||||||
|
git add delnew &&
|
||||||
|
git diff --cached >> new.patch &&
|
||||||
|
git reset --hard &&
|
||||||
|
test_write_lines 1 > delnew &&
|
||||||
|
git add delnew &&
|
||||||
|
git commit -m "delnew" &&
|
||||||
|
rm delnew &&
|
||||||
|
git diff >> delete-then-new.patch &&
|
||||||
|
cat new.patch >> delete-then-new.patch &&
|
||||||
|
|
||||||
|
git checkout -- . &&
|
||||||
|
# Apply must succeed.
|
||||||
|
git apply --3way delete-then-new.patch
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue