Package org.eclipse.jgit.api
Class DiffCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<java.util.List<DiffEntry>>
-
- org.eclipse.jgit.api.DiffCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.util.List<DiffEntry>>
public class DiffCommand extends GitCommand<java.util.List<DiffEntry>>
Show changes between commits, commit and working tree, etc.- See Also:
- Git documentation about diff
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
cached
private int
contextLines
private java.lang.String
destinationPrefix
private ProgressMonitor
monitor
private AbstractTreeIterator
newTree
private AbstractTreeIterator
oldTree
private java.io.OutputStream
out
private TreeFilter
pathFilter
private boolean
showNameAndStatusOnly
private java.lang.String
sourcePrefix
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DiffCommand(Repository repo)
Constructor for DiffCommand
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<DiffEntry>
call()
private DiffFormatter
getDiffFormatter()
DiffCommand
setCached(boolean cached)
Whether to view the changes staged for the next commitDiffCommand
setContextLines(int contextLines)
Set number of context lines instead of the usual three.DiffCommand
setDestinationPrefix(java.lang.String destinationPrefix)
Set the given destination prefix instead of "b/".DiffCommand
setNewTree(AbstractTreeIterator newTree)
Set new treeDiffCommand
setOldTree(AbstractTreeIterator oldTree)
Set old treeDiffCommand
setOutputStream(java.io.OutputStream out)
Set output streamDiffCommand
setPathFilter(TreeFilter pathFilter)
Set path filterDiffCommand
setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the diff operation.DiffCommand
setShowNameAndStatusOnly(boolean showNameAndStatusOnly)
Set whether to return only names and status of changed filesDiffCommand
setSourcePrefix(java.lang.String sourcePrefix)
Set the given source prefix instead of "a/".-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Field Detail
-
oldTree
private AbstractTreeIterator oldTree
-
newTree
private AbstractTreeIterator newTree
-
cached
private boolean cached
-
pathFilter
private TreeFilter pathFilter
-
showNameAndStatusOnly
private boolean showNameAndStatusOnly
-
out
private java.io.OutputStream out
-
contextLines
private int contextLines
-
sourcePrefix
private java.lang.String sourcePrefix
-
destinationPrefix
private java.lang.String destinationPrefix
-
monitor
private ProgressMonitor monitor
-
-
Constructor Detail
-
DiffCommand
protected DiffCommand(Repository repo)
Constructor for DiffCommand- Parameters:
repo
- aRepository
object.
-
-
Method Detail
-
getDiffFormatter
private DiffFormatter getDiffFormatter()
-
call
public java.util.List<DiffEntry> call() throws GitAPIException
Execute the command
Executes the
Diff
command with all the options and parameters collected by the setter methods (e.g.setCached(boolean)
of this class. Each instance of this class should only be used for one invocation of the command. Don't call this method twice on an instance.- Specified by:
call
in interfacejava.util.concurrent.Callable<java.util.List<DiffEntry>>
- Specified by:
call
in classGitCommand<java.util.List<DiffEntry>>
- Throws:
GitAPIException
-
setCached
public DiffCommand setCached(boolean cached)
Whether to view the changes staged for the next commit- Parameters:
cached
- whether to view the changes staged for the next commit- Returns:
- this instance
-
setPathFilter
public DiffCommand setPathFilter(TreeFilter pathFilter)
Set path filter- Parameters:
pathFilter
- parameter, used to limit the diff to the named path- Returns:
- this instance
-
setOldTree
public DiffCommand setOldTree(AbstractTreeIterator oldTree)
Set old tree- Parameters:
oldTree
- the previous state- Returns:
- this instance
-
setNewTree
public DiffCommand setNewTree(AbstractTreeIterator newTree)
Set new tree- Parameters:
newTree
- the updated state- Returns:
- this instance
-
setShowNameAndStatusOnly
public DiffCommand setShowNameAndStatusOnly(boolean showNameAndStatusOnly)
Set whether to return only names and status of changed files- Parameters:
showNameAndStatusOnly
- whether to return only names and status of changed files- Returns:
- this instance
-
setOutputStream
public DiffCommand setOutputStream(java.io.OutputStream out)
Set output stream- Parameters:
out
- the stream to write line data- Returns:
- this instance
-
setContextLines
public DiffCommand setContextLines(int contextLines)
Set number of context lines instead of the usual three.- Parameters:
contextLines
- the number of context lines- Returns:
- this instance
-
setSourcePrefix
public DiffCommand setSourcePrefix(java.lang.String sourcePrefix)
Set the given source prefix instead of "a/".- Parameters:
sourcePrefix
- the prefix- Returns:
- this instance
-
setDestinationPrefix
public DiffCommand setDestinationPrefix(java.lang.String destinationPrefix)
Set the given destination prefix instead of "b/".- Parameters:
destinationPrefix
- the prefix- Returns:
- this instance
-
setProgressMonitor
public DiffCommand setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the diff operation. By default, this is set toNullProgressMonitor
- Parameters:
monitor
- a progress monitor- Returns:
- this instance
- See Also:
NullProgressMonitor
-
-