Top Description Fields Constructors Methods
org.eclipse.jgit.api

public Class DiffCommand

extends GitCommand<List<DiffEntry>>
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.HEAD

Show changes between commits, commit and working tree, etc.
See Also
Git documentation about diff

Field Summary

Modifier and TypeField and Description
private boolean
private int
private String
private ProgressMonitor
private AbstractTreeIterator
private AbstractTreeIterator
private OutputStream
private TreeFilter
private boolean
private boolean
private String
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
protected
DiffCommand(Repository repo)

Constructor for DiffCommand

Method Summary

Modifier and TypeMethod and Description
public List<DiffEntry>
call()

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

private DiffFormatter
public DiffCommand

Returns:

this instance
setCached
(boolean
whether to view the changes staged for the next commit
cached
)

Whether to view the changes staged for the next commit

public DiffCommand

Returns:

this instance
setContextLines
(int
the number of context lines
contextLines
)

Set number of context lines instead of the usual three.

public DiffCommand

Returns:

this instance
setDestinationPrefix
(String
the prefix
destinationPrefix
)

Set the given destination prefix instead of "b/".

public DiffCommand

Returns:

this instance
setNewTree
(AbstractTreeIterator
the updated state
newTree
)

Set new tree

public DiffCommand

Returns:

this instance
setOldTree
(AbstractTreeIterator
the previous state
oldTree
)

Set old tree

public DiffCommand

Returns:

this instance
setOutputStream
(OutputStream
the stream to write line data
out
)

Set output stream

public DiffCommand

Returns:

this instance
setPathFilter
(TreeFilter
parameter, used to limit the diff to the named path
pathFilter
)

Set path filter

public DiffCommand

Returns:

this instance
setProgressMonitor
(ProgressMonitor
a progress monitor
monitor
)

The progress monitor associated with the diff operation.

public DiffCommand

Returns:

this instance
setShowNameAndStatusOnly
(boolean
whether to return only names and status of changed files
showNameAndStatusOnly
)

Set whether to return only names and status of changed files

public DiffCommand

Returns:

this instance
setShowNameOnly
(boolean
whether to return only names files
showNameOnly
)

Set whether to return only names of changed files

public DiffCommand

Returns:

this instance
setSourcePrefix
(String
the prefix
sourcePrefix
)

Set the given source prefix instead of "a/".

Inherited from org.eclipse.jgit.api.GitCommand:
checkCallablegetRepositorysetCallable

Field Detail

cachedback to summary
private boolean cached
contextLinesback to summary
private int contextLines
destinationPrefixback to summary
private String destinationPrefix
monitorback to summary
private ProgressMonitor monitor
newTreeback to summary
private AbstractTreeIterator newTree
oldTreeback to summary
private AbstractTreeIterator oldTree
outback to summary
private OutputStream out
pathFilterback to summary
private TreeFilter pathFilter
showNameAndStatusOnlyback to summary
private boolean showNameAndStatusOnly
showNameOnlyback to summary
private boolean showNameOnly
sourcePrefixback to summary
private String sourcePrefix

Constructor Detail

DiffCommandback to summary
protected DiffCommand(Repository repo)

Constructor for DiffCommand

Parameters
repo:Repository

a org.eclipse.jgit.lib.Repository object.

Method Detail

callback to summary
public List<DiffEntry> call() throws GitAPIException

Implements abstract org.eclipse.jgit.api.GitCommand.call.

Implements java.util.concurrent.Callable.call.

Doc from org.eclipse.jgit.api.GitCommand.call.

Computes a result, or throws an exception if unable to do so.

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.

Returns:List<DiffEntry>

Doc from java.util.concurrent.Callable.call.

computed result

Annotations
@Override
getDiffFormatterback to summary
private DiffFormatter getDiffFormatter()
setCachedback to summary
public DiffCommand setCached(boolean cached)

Whether to view the changes staged for the next commit

Parameters
cached:boolean

whether to view the changes staged for the next commit

Returns:DiffCommand

this instance

setContextLinesback to summary
public DiffCommand setContextLines(int contextLines)

Set number of context lines instead of the usual three.

Parameters
contextLines:int

the number of context lines

Returns:DiffCommand

this instance

setDestinationPrefixback to summary
public DiffCommand setDestinationPrefix(String destinationPrefix)

Set the given destination prefix instead of "b/".

Parameters
destinationPrefix:String

the prefix

Returns:DiffCommand

this instance

setNewTreeback to summary
public DiffCommand setNewTree(AbstractTreeIterator newTree)

Set new tree

Parameters
newTree:AbstractTreeIterator

the updated state

Returns:DiffCommand

this instance

setOldTreeback to summary
public DiffCommand setOldTree(AbstractTreeIterator oldTree)

Set old tree

Parameters
oldTree:AbstractTreeIterator

the previous state

Returns:DiffCommand

this instance

setOutputStreamback to summary
public DiffCommand setOutputStream(OutputStream out)

Set output stream

Parameters
out:OutputStream

the stream to write line data

Returns:DiffCommand

this instance

setPathFilterback to summary
public DiffCommand setPathFilter(TreeFilter pathFilter)

Set path filter

Parameters
pathFilter:TreeFilter

parameter, used to limit the diff to the named path

Returns:DiffCommand

this instance

setProgressMonitorback to summary
public DiffCommand setProgressMonitor(ProgressMonitor monitor)

The progress monitor associated with the diff operation. By default, this is set to NullProgressMonitor

Parameters
monitor:ProgressMonitor

a progress monitor

Returns:DiffCommand

this instance

See Also
NullProgressMonitor
setShowNameAndStatusOnlyback to summary
public DiffCommand setShowNameAndStatusOnly(boolean showNameAndStatusOnly)

Set whether to return only names and status of changed files

Parameters
showNameAndStatusOnly:boolean

whether to return only names and status of changed files

Returns:DiffCommand

this instance

setShowNameOnlyback to summary
public DiffCommand setShowNameOnly(boolean showNameOnly)

Set whether to return only names of changed files

Parameters
showNameOnly:boolean

whether to return only names files

Returns:DiffCommand

this instance

Since
6.4
setSourcePrefixback to summary
public DiffCommand setSourcePrefix(String sourcePrefix)

Set the given source prefix instead of "a/".

Parameters
sourcePrefix:String

the prefix

Returns:DiffCommand

this instance