diff --git a/pom.xml b/pom.xml
index 151cbea..e2352a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,174 +1,200 @@
- 4.0.0
- com.github.java-diff-utils
- diffutils
- jar
- 1.4.0-SNAPSHOT
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ com.github.java-diff-utils
+ diffutils
+ jar
+ 1.4.0-SNAPSHOT
- java-diff-utils
- The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.
- https://github.com/wumpz/java-diff-utils
- 2009
-
- org.sonatype.oss
- oss-parent
- 9
-
-
- scm:git:https://github.com/wumpz/java-diff-utils.git
- scm:git:ssh://git@github.com:wumpz/java-diff-utils.git
- https://github.com/wumpz/java-diff-utils.git
-
+ java-diff-utils
+ The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.
+ https://github.com/wumpz/java-diff-utils
+ 2009
+
+ org.sonatype.oss
+ oss-parent
+ 9
+
+
+ scm:git:https://github.com/wumpz/java-diff-utils.git
+ scm:git:ssh://git@github.com:wumpz/java-diff-utils.git
+ https://github.com/wumpz/java-diff-utils.git
+
-
- GitHub Issues
- https://github.com/wumpz/java-diff-utils/issues
-
+
+ GitHub Issues
+ https://github.com/wumpz/java-diff-utils/issues
+
-
- java-diff-utils
-
+
+ java-diff-utils
+
-
-
- Tobias Warneke
- t.warneke@gmx.net
-
-
- Dmitry Naumenko
- dm.naumenko@gmail.com
-
-
- Juanco Anez
- juanco@suigeneris.org
-
-
+
+
+ Tobias Warneke
+ t.warneke@gmx.net
+
+
+ Dmitry Naumenko
+ dm.naumenko@gmail.com
+
+
+ Juanco Anez
+ juanco@suigeneris.org
+
+
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
- A business-friendly OSS license
-
-
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+ A business-friendly OSS license
+
+
-
- UTF-8
-
+
+ UTF-8
+
-
-
- junit
- junit
- 4.12
- jar
- test
-
-
- org.eclipse.jgit
- org.eclipse.jgit
- 4.4.1.201607150455-r
-
-
+
+
+ junit
+ junit
+ 4.12
+ jar
+ test
+
+
+ org.eclipse.jgit
+ org.eclipse.jgit
+ 4.4.1.201607150455-r
+
+
+ com.googlecode.javaewah
+ JavaEWAH
+
+
+ commons-codec
+ commons-codec
+
+
+ commons-logging
+ commons-logging
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ com.jcraft
+ jsch
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+
-
-
+
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.6.1
-
- 1.8
- 1.8
- UTF-8
-
-
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+ 1.8
+ 1.8
+ UTF-8
+
+
-
-
-
- maven-jar-plugin
- 3.0.2
-
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
- 3.3.0
-
-
- bundle-manifest
- process-classes
-
- manifest
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.10.4
-
- ${javadoc.opts}
-
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
-
-
-
-
- doclint-java8-disable
-
- [1.8,)
-
-
- -Xdoclint:none
-
-
-
+
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ ${project.build.outputDirectory}/META-INF/MANIFEST.MF
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 3.3.0
+
+
+ bundle-manifest
+ process-classes
+
+ manifest
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.10.4
+
+ ${javadoc.opts}
+
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+
+
+
+
+ doclint-java8-disable
+
+ [1.8,)
+
+
+ -Xdoclint:none
+
+
+
diff --git a/src/main/java/difflib/algorithm/jgit/JGitDiff.java b/src/main/java/difflib/algorithm/jgit/JGitDiff.java
index 5d338e8..23d2a26 100644
--- a/src/main/java/difflib/algorithm/jgit/JGitDiff.java
+++ b/src/main/java/difflib/algorithm/jgit/JGitDiff.java
@@ -30,7 +30,9 @@ import org.eclipse.jgit.diff.Sequence;
import org.eclipse.jgit.diff.SequenceComparator;
/**
- *
+ * HistorgramDiff using JGit - Library. This one is much more performant than the
+ * orginal Myers implementation.
+ *
* @author toben
*/
public class JGitDiff implements DiffAlgorithm {
@@ -41,8 +43,6 @@ public class JGitDiff implements DiffAlgorithm {
diffList.addAll(new HistogramDiff().diff(new DataListComparator<>(), new DataList<>(original), new DataList<>(revised)));
Patch patch = new Patch<>();
for (Edit edit : diffList) {
- System.out.println(edit);
-
Chunk orgChunk = new Chunk<>(edit.getBeginA(), original.subList(edit.getBeginA(), edit.getEndA()));
Chunk revChunk = new Chunk<>(edit.getBeginA(), revised.subList(edit.getBeginB(), edit.getEndB()));
switch (edit.getType()) {
diff --git a/src/test/java/difflib/algorithm/jgit/JGitDiffTest.java b/src/test/java/difflib/algorithm/jgit/JGitDiffTest.java
index bfef1a4..b075a81 100644
--- a/src/test/java/difflib/algorithm/jgit/JGitDiffTest.java
+++ b/src/test/java/difflib/algorithm/jgit/JGitDiffTest.java
@@ -15,12 +15,15 @@
*/
package difflib.algorithm.jgit;
-import difflib.DiffUtils;
+import static difflib.DiffUtilsTest.readStringListFromInputStream;
+import difflib.TestConstants;
import difflib.algorithm.DiffException;
import difflib.patch.Patch;
import difflib.patch.PatchFailedException;
+import java.io.IOException;
import java.util.Arrays;
import java.util.List;
+import java.util.zip.ZipFile;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -70,4 +73,18 @@ public class JGitDiffTest {
assertEquals(revList, patched);
}
+ @Test
+ public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, DiffException, PatchFailedException {
+ ZipFile zip = new ZipFile(TestConstants.MOCK_FOLDER + "/large_dataset1.zip");
+ List original = readStringListFromInputStream(zip.getInputStream(zip.getEntry("ta")));
+ List revised = readStringListFromInputStream(zip.getInputStream(zip.getEntry("tb")));
+
+ Patch patch = new JGitDiff().diff(original, revised);
+
+ assertEquals(34, patch.getDeltas().size());
+
+ List created = patch.applyTo(original);
+ assertArrayEquals(revised.toArray(), created.toArray());
+ }
+
}