]> source.dussan.org Git - jgit.git/commit
Allow applying a patch with conflicts 80/200480/10
authorPatrick Hiesel <hiesel@google.com>
Fri, 10 Mar 2023 15:50:37 +0000 (16:50 +0100)
committerPatrick Hiesel <hiesel@google.com>
Tue, 14 May 2024 16:52:47 +0000 (18:52 +0200)
commit6e9a170364efc727f4368cf5304115c7b278a649
tree15d27c0e3b1fbd2a882a10b3a5fcbd803e0a503d
parent5c0c18f5665fe8d3c3fae0176e231deb6c2480a7
Allow applying a patch with conflicts

In some settings, we want to let users apply a patch that does
not cleanly apply and add conflict markers. In Gerrit, this is
useful when cherry picking (via Git patches) from one host to
another.

This commit takes a simple approach: If a hunk doesn't apply,
go to the pre-image line, treat all lines in pre-image length
as left side of the conflict and all context and newly added
lines as right side of the conflict.

Change-Id: I01411d7a32b3f3207097b26231909aae6b835650
org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ConflictOutOfBounds.patch [new file with mode: 0644]
org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ConflictOutOfBounds_PostImage [new file with mode: 0644]
org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/ConflictOutOfBounds_PreImage [new file with mode: 0644]
org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/allowconflict.patch [new file with mode: 0644]
org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/allowconflict_PostImage [new file with mode: 0644]
org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/allowconflict_PreImage [new file with mode: 0644]
org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchApplierTest.java
org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java