diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-09-02 12:53:27 -0700 |
---|---|---|
committer | Chris Aniszczyk <caniszczyk@gmail.com> | 2010-09-06 21:37:11 -0500 |
commit | 67263e2056108e471d684c3cef9e719724b51220 (patch) | |
tree | e4ea7623e4b0884b542c77167ab456e3643eb5ed /org.eclipse.jgit.pgm/src | |
parent | 18aadc826dae7c6308c2a6c68d48ab75c8dd9b6d (diff) | |
download | jgit-67263e2056108e471d684c3cef9e719724b51220.tar.gz jgit-67263e2056108e471d684c3cef9e719724b51220.zip |
Refactor diff sequence API
Instead of making the sequence itself responsible for the equivalence
function, use an external function that is supplied by the caller.
This cleans up the code because we now say cmp.equals(a, ai, b, bi)
instead of a.equals(ai, b, bi).
This refactoring also removes the odd concept of creating different
types of sequences to have different behaviors for whitespace
ignoring. Instead DiffComparator now supports singleton functions
that apply a particular equivalence algorithm to a type of sequence.
Change-Id: I559f494d81cdc6f06bfb4208f60780c0ae251df9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java | 13 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java | 13 |
2 files changed, 10 insertions, 16 deletions
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 7a4aed71ea..a5f801b296 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 @@ -55,10 +55,7 @@ import java.util.List; import org.eclipse.jgit.diff.DiffEntry; import org.eclipse.jgit.diff.DiffFormatter; -import org.eclipse.jgit.diff.RawTextIgnoreAllWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreLeadingWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreTrailingWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreWhitespaceChange; +import org.eclipse.jgit.diff.RawTextComparator; import org.eclipse.jgit.diff.RenameDetector; import org.eclipse.jgit.dircache.DirCacheIterator; import org.eclipse.jgit.lib.ObjectId; @@ -109,22 +106,22 @@ class Diff extends TextBuiltin { @Option(name = "--ignore-space-at-eol") void ignoreSpaceAtEol(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreTrailingWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_TRAILING); } @Option(name = "--ignore-leading-space") void ignoreLeadingSpace(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreLeadingWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_LEADING); } @Option(name = "-b", aliases = { "--ignore-space-change" }) void ignoreSpaceChange(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreWhitespaceChange.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_CHANGE); } @Option(name = "-w", aliases = { "--ignore-all-space" }) void ignoreAllSpace(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreAllWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_ALL); } @Option(name = "-U", aliases = { "--unified" }, metaVar = "metaVar_linesOfContext") diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 92cb70d4c4..0ce774b27d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -58,10 +58,7 @@ import java.util.Set; import java.util.TimeZone; import org.eclipse.jgit.diff.DiffFormatter; -import org.eclipse.jgit.diff.RawTextIgnoreAllWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreLeadingWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreTrailingWhitespace; -import org.eclipse.jgit.diff.RawTextIgnoreWhitespaceChange; +import org.eclipse.jgit.diff.RawTextComparator; import org.eclipse.jgit.diff.RenameDetector; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; @@ -106,22 +103,22 @@ class Log extends RevWalkTextBuiltin { @Option(name = "--ignore-space-at-eol") void ignoreSpaceAtEol(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreTrailingWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_TRAILING); } @Option(name = "--ignore-leading-space") void ignoreLeadingSpace(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreLeadingWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_LEADING); } @Option(name = "-b", aliases = { "--ignore-space-change" }) void ignoreSpaceChange(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreWhitespaceChange.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_CHANGE); } @Option(name = "-w", aliases = { "--ignore-all-space" }) void ignoreAllSpace(@SuppressWarnings("unused") boolean on) { - diffFmt.setRawTextFactory(RawTextIgnoreAllWhitespace.FACTORY); + diffFmt.setDiffComparator(RawTextComparator.WS_IGNORE_ALL); } @Option(name = "-U", aliases = { "--unified" }, metaVar = "metaVar_linesOfContext") |