Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Lay2012-01-09 12:06:59 +0000
committerCode Review2012-01-09 12:06:59 +0000
commit8f742cdd1005d0ddef3a826c277ba0b2983a4c2d (patch)
tree27317a51283ac86a8ff9cd95a949bb562dcfeb4d /org.eclipse.jgit
parent885a38983243d22fb756516ee108ec9ca909a9af (diff)
parent69a5683b827c1b97113a13974509321be3d67e49 (diff)
downloadjgit-8f742cdd1005d0ddef3a826c277ba0b2983a4c2d.tar.gz
jgit-8f742cdd1005d0ddef3a826c277ba0b2983a4c2d.tar.xz
jgit-8f742cdd1005d0ddef3a826c277ba0b2983a4c2d.zip
Merge "Add options for setting context lines and prefixes to DiffCommand"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
index 5fff5b5f55..8143bc7b63 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/DiffCommand.java
@@ -82,6 +82,12 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
private OutputStream out;
+ private int contextLines = -1;
+
+ private String sourcePrefix;
+
+ private String destinationPrefix;
+
/**
* @param repo
*/
@@ -125,6 +131,12 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
}
diffFmt.setPathFilter(pathFilter);
+ if (contextLines >= 0)
+ diffFmt.setContext(contextLines);
+ if (destinationPrefix != null)
+ diffFmt.setNewPrefix(destinationPrefix);
+ if (sourcePrefix != null)
+ diffFmt.setOldPrefix(sourcePrefix);
List<DiffEntry> result = diffFmt.scan(oldTree, newTree);
if (showNameAndStatusOnly) {
@@ -199,4 +211,40 @@ public class DiffCommand extends GitCommand<List<DiffEntry>> {
this.out = out;
return this;
}
+
+ /**
+ * Set number of context lines instead of the usual three.
+ *
+ * @param contextLines
+ * the number of context lines
+ * @return this instance
+ */
+ public DiffCommand setContextLines(int contextLines) {
+ this.contextLines = contextLines;
+ return this;
+ }
+
+ /**
+ * Set the given source prefix instead of "a/".
+ *
+ * @param sourcePrefix
+ * the prefix
+ * @return this instance
+ */
+ public DiffCommand setSourcePrefix(String sourcePrefix) {
+ this.sourcePrefix = sourcePrefix;
+ return this;
+ }
+
+ /**
+ * Set the given destination prefix instead of "b/".
+ *
+ * @param destinationPrefix
+ * the prefix
+ * @return this instance
+ */
+ public DiffCommand setDestinationPrefix(String destinationPrefix) {
+ this.destinationPrefix = destinationPrefix;
+ return this;
+ }
} \ No newline at end of file

Back to the top