]> source.dussan.org Git - jgit.git/commitdiff
PatchApplier: Add test for conflict markers on a deleted file 91/1195291/2
authorPatrick Hiesel <hiesel@google.com>
Mon, 27 May 2024 08:16:34 +0000 (10:16 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 27 May 2024 16:02:05 +0000 (18:02 +0200)
For deleted files, we want to keep erroring out even if conflicts
are allowed for the apply patch logic. The resulting file would
otherwise only consist of the patch.

Change-Id: I18defa627ad2223a3a917d2b0ee4189396732533

org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/allowconflict_file_deleted.patch [new file with mode: 0644]
org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/PatchApplierTest.java

diff --git a/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/allowconflict_file_deleted.patch b/org.eclipse.jgit.test/tst-rsrc/org/eclipse/jgit/diff/allowconflict_file_deleted.patch
new file mode 100644 (file)
index 0000000..c9655a5
--- /dev/null
@@ -0,0 +1,10 @@
+diff --git a/allowconflict_file_deleted b/allowconflict_file_deleted
+index 0000000..de98044
+--- a/allowconflict_file_deleted
++++ b/allowconflict_file_deleted
+@@ -3,4 +3,4 @@
+ line3
+-lineA
++lineB
+ line5
+ line6
index 2e529b5e932e3d7152fc9963d6a6d67629db903d..8f3478db187d7c6374157bfd654730e2e2ad01fd 100644 (file)
@@ -395,6 +395,16 @@ public class PatchApplierTest {
                        verifyChange(result, "ConflictOutOfBounds", true, 1);
                }
 
+               @Test
+               public void testConflictMarkersFileDeleted() throws Exception {
+                       init("allowconflict_file_deleted", false, false);
+
+                       Result result = applyPatchAllowConflicts();
+
+                       assertEquals(1, result.getErrors().size());
+                       assertEquals(0, result.getPaths().size());
+               }
+
                @Test
                public void testShiftUp() throws Exception {
                        init("ShiftUp");