From 049827d7080201fe24f2728b26d681434327f72a Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Fri, 26 Nov 2010 00:30:08 +0100 Subject: Make diff algorithm configurable The diff algorithm which is used by Merge, Cherry-Pick, Rebase should be configurable. A new configuration parameter "diff.algorithm" is introduced which currently accepts the values "myers" or "histogram". Based on this parameter for example the ResolveMerger will choose a diff algorithm. The reason for this is bug 331078. This bug shows that JGit is more compatible with C Git when histogram diff is in place. But since histogram diff is quite new we need an easy way to fall back to Myers diff. Bug: 331078 Change-Id: I2549c992e478d991c61c9508ad826d1a9e539ae3 Signed-off-by: Christian Halstrick Signed-off-by: Philipp Thun --- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'org.eclipse.jgit.pgm') 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 6062f35827..506031713a 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 @@ -54,10 +54,9 @@ import java.text.MessageFormat; import java.util.List; import org.eclipse.jgit.diff.DiffAlgorithm; +import org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm; 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; @@ -101,19 +100,9 @@ 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", metaVar = "metaVar_diffAlg", usage = "usage_diffAlgorithm") void setAlgorithm(SupportedAlgorithm s) { - diffFmt.setDiffAlgorithm(s.algorithm); + diffFmt.setDiffAlgorithm(DiffAlgorithm.getAlgorithm(s)); } @Option(name = "-l", usage = "usage_renameLimit") -- cgit v1.2.3