Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions KEYS
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: Benutzer-ID: Tobias Warneke
Comment: Fingerabdruck: D477D51812E692011DB11E66A6EA2E2BF22E0543


mQGNBFJQhigBDADpuhND/VUQwJT0nnJxfjAIur59hyaZZ3Ph/KIgmCneyq7lzYO6
xa1ucH8mqNBVNLLBhs4CjihBddU/ZKTX3WnZyhQKQMZr3Tg+TCNFmAR4/hnZ3NjZ
N5N5gUj/dqVI2rIvypIuxUApl88BYMsxYpn2+8FKeMd8oBJLqFRJ3WNjB4Op2tRO
XRWoxs1ypubS/IV1zkphHHpi6VSABlTyTWu4kXEj/1/GpsdtHRa9kvdWw7yKQbnM
XuwOxtzZFJcyu0P2jYVfHHvxcjxuklc9edmCGdNxgKIoo0LXZOeFIi6OWtwzD0pn
O6ovJ+PL9QscMdnQlPwsiCwjNUNue20GBv3aUIYc+Z8Gq0SqSan5V0IiKRHMJkzd
FAhnpkSFBvHhPJn07BCcb1kctqL+xnLxIdi7arq3WNA/6bJjsojc/x3FdIvORIeP
sqejhtL8mCBvbMAMHSBrFxclMp+HSz2ouHEEPIQam0KeN8t1yEqIy3/aYKMzHj9c
C3s8XOaBCbJbKpMAEQEAAbQ9VG9iaWFzIFdhcm5la2UgKGZvciBkZXZlbG9wbWVu
dCBwdXJwb3NlcykgPHQud2FybmVrZUBnbXgubmV0PokBvwQTAQIAKQUCUlCGKAIb
DwUJCWav+AcLCQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAAAoJEKbqLivyLgVD/8IL
+gPYvGZcd52WqUqXlZQQQWheMNGlxKd85MV0Kf1TlukHEzaC2XE0Hjz3RNWBroL2
QZ+CR/17XX9+10VCAdDYtArClFo85B1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LjZiQHWBBMB
CABAAhsPBwsJCAcDAgEGFQgCCQoLBBYCAwECHgECF4AWIQTUd9UYEuaSAR2xHmam
6i4r8i4FQwUCX58d7AUJERB2CAAKCRCm6i4r8i4FQ8COC/4i8YPxqtk/Z6nEHXSc
3F6GB0He9UZG8LMBbLD93nooHAY3VzOaUcg0/8SN+HhtFmAVcgshKpx/7ysBO8hK
wKArPN+W458O4VGm6pmKyuVqoSkOpQYrZHzHuTEBFoHYbeDh3LrHIlnC//l18U9A
n9pCN42RFKhcjhZYs17FkHcTQbH1rcXfZe+vzu+70ZyGyh+3FB+32OgW6lGD6QKK
lD7DfoP2BaYVe2OlhPdZ2ubQBw/qV7Or5KlzBWff4Nbv2nT9Y4uFGvo01CxEEi4z
mc0hsK3yGeP26V49kZy3PAJNjyy4gPhG7Xw06JTw0rO2hcgjtdGWgH2/l7PCS0qg
PPBMGDCbb5cz++8YWUHT0togJ2K49BqKpJlt4soqYFPWFMS0QeI90yV3YeWOL+tV
hLcJ6K/RhSg6eagAASa0AbuCGkgnHJW1ZlyFnnketvihTkCe2yGvBgxY1F7S2jGN
B2zkOzYjaWqSN5SlpSNBcSY8NLWGdyQoDEjY+I56J+IuWPE=
=H+XU
-----END PGP PUBLIC KEY BLOCK-----
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Main reason to build this library was the lack of easy-to-use libraries with all

**This is originally a fork of java-diff-utils from Google Code Archive.**

## GPG Signature Validation

The gpg singing key in [KEYS] is used for this projects artifacts.

## API

Javadocs of the actual release version: [JavaDocs java-diff-utils](https://java-diff-utils.github.io/java-diff-utils/4.10/docs/apidocs/)
Expand Down
110 changes: 55 additions & 55 deletions java-diff-utils-jgit/pom.xml
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils-parent</artifactId>
<version>4.16-SNAPSHOT</version>
</parent>
<artifactId>java-diff-utils-jgit</artifactId>
<name>java-diff-utils-jgit</name>
<packaging>jar</packaging>
<description>This is an extension of java-diff-utils using jgit to use its implementation of
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils-parent</artifactId>
<version>4.16-SNAPSHOT</version>
</parent>
<artifactId>java-diff-utils-jgit</artifactId>
<packaging>jar</packaging>
<name>java-diff-utils-jgit</name>
<description>This is an extension of java-diff-utils using jgit to use its implementation of
some difference algorithms.</description>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- no upgrade possible till base JDK upgrade to 17 -->
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.13.3.202401111512-r</version>
<exclusions>
<exclusion>
<groupId>com.googlecode.javaewah</groupId>
<artifactId>JavaEWAH</artifactId>
</exclusion>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>java-diff-utils</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- no upgrade possible till base JDK upgrade to 17 -->
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.13.3.202401111512-r</version>
<exclusions>
<exclusion>
<groupId>com.googlecode.javaewah</groupId>
<artifactId>JavaEWAH</artifactId>
</exclusion>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>java-diff-utils</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,71 +35,71 @@
*/
public class HistogramDiff<T> implements DiffAlgorithmI<T> {

@Override
public List<Change> computeDiff(List<T> source, List<T> target, DiffAlgorithmListener progress) {
Objects.requireNonNull(source, "source list must not be null");
Objects.requireNonNull(target, "target list must not be null");
if (progress != null) {
progress.diffStart();
}
EditList diffList = new EditList();
diffList.addAll(new org.eclipse.jgit.diff.HistogramDiff().diff(new DataListComparator<>(progress), new DataList<>(source), new DataList<>(target)));
List<Change> patch = new ArrayList<>();
for (Edit edit : diffList) {
DeltaType type = DeltaType.EQUAL;
switch (edit.getType()) {
case DELETE:
type = DeltaType.DELETE;
break;
case INSERT:
type = DeltaType.INSERT;
break;
case REPLACE:
type = DeltaType.CHANGE;
break;
}
patch.add(new Change(type, edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB()));
}
if (progress != null) {
progress.diffEnd();
}
return patch;
}
@Override
public List<Change> computeDiff(List<T> source, List<T> target, DiffAlgorithmListener progress) {
Objects.requireNonNull(source, "source list must not be null");
Objects.requireNonNull(target, "target list must not be null");
if (progress != null) {
progress.diffStart();
}
EditList diffList = new EditList();
diffList.addAll(new org.eclipse.jgit.diff.HistogramDiff()
.diff(new DataListComparator<>(progress), new DataList<>(source), new DataList<>(target)));
List<Change> patch = new ArrayList<>();
for (Edit edit : diffList) {
DeltaType type = DeltaType.EQUAL;
switch (edit.getType()) {
case DELETE:
type = DeltaType.DELETE;
break;
case INSERT:
type = DeltaType.INSERT;
break;
case REPLACE:
type = DeltaType.CHANGE;
break;
}
patch.add(new Change(type, edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB()));
}
if (progress != null) {
progress.diffEnd();
}
return patch;
}
}

class DataListComparator<T> extends SequenceComparator<DataList<T>> {

private final DiffAlgorithmListener progress;
private final DiffAlgorithmListener progress;

public DataListComparator(DiffAlgorithmListener progress) {
this.progress = progress;
}
public DataListComparator(DiffAlgorithmListener progress) {
this.progress = progress;
}

@Override
public boolean equals(DataList<T> original, int orgIdx, DataList<T> revised, int revIdx) {
if (progress != null) {
progress.diffStep(orgIdx + revIdx, original.size() + revised.size());
}
return original.data.get(orgIdx).equals(revised.data.get(revIdx));
}

@Override
public int hash(DataList<T> s, int i) {
return s.data.get(i).hashCode();
}
@Override
public boolean equals(DataList<T> original, int orgIdx, DataList<T> revised, int revIdx) {
if (progress != null) {
progress.diffStep(orgIdx + revIdx, original.size() + revised.size());
}
return original.data.get(orgIdx).equals(revised.data.get(revIdx));
}

@Override
public int hash(DataList<T> s, int i) {
return s.data.get(i).hashCode();
}
}

class DataList<T> extends Sequence {

final List<T> data;
final List<T> data;

public DataList(List<T> data) {
this.data = data;
}
public DataList(List<T> data) {
this.data = data;
}

@Override
public int size() {
return data.size();
}
@Override
public int size() {
return data.size();
}
}
Loading