From e10808e6585fe16956bda294bcc3ffbaa1410a1c Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Tue, 26 Oct 2010 18:04:35 +0200 Subject: Add option to select diff algorithm for diff command The diff command in the pgm package was enhanced to allow choosing the diff algorithm (currently myers or histogram) Change-Id: I72083e78fb5c92868eb5d8ec512277d212a39349 Signed-off-by: Christian Halstrick --- .../src/org/eclipse/jgit/pgm/Diff.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'org.eclipse.jgit.pgm/src') diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java index a5f801b296..19d11d629e 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java @@ -53,8 +53,11 @@ import java.io.PrintWriter; import java.text.MessageFormat; import java.util.List; +import org.eclipse.jgit.diff.DiffAlgorithm; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.DiffFormatter; +import org.eclipse.jgit.diff.HistogramDiff; +import org.eclipse.jgit.diff.MyersDiff; import org.eclipse.jgit.diff.RawTextComparator; import org.eclipse.jgit.diff.RenameDetector; import org.eclipse.jgit.dircache.DirCacheIterator; @@ -98,6 +101,21 @@ class Diff extends TextBuiltin { detectRenames = Boolean.FALSE; } + enum SupportedAlgorithm { + myers(MyersDiff.INSTANCE), histogram(new HistogramDiff()); + + public DiffAlgorithm algorithm; + + SupportedAlgorithm(DiffAlgorithm a) { + algorithm = a; + } + }; + + @Option(name = "--algorithm", usage = "usage_diffAlgorithm") + void setAlgorithm(SupportedAlgorithm s) { + diffFmt.setDiffAlgorithm(s.algorithm); + } + @Option(name = "-l", usage = "usage_renameLimit") private Integer renameLimit; -- cgit v1.2.3