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

public Class RevertCommand

extends GitCommand<RevCommit>
Class Inheritance
Static Imports
org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH

A class used to execute a revert command. It has setters for all supported options and arguments of this command and a call() method to finally execute the command. Each instance of this class should only be used for one invocation of the command (means: one call to call())
See Also
Git documentation about revert

Field Summary

Modifier and TypeField and Description
private List<Ref>
private MergeResult
private boolean
private ProgressMonitor
private String
private List<Ref>
private MergeStrategy
private List<String>
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
protected
RevertCommand(Repository repo)

Constructor for RevertCommand.

Method Summary

Modifier and TypeMethod and Description
private String
public RevCommit
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.

public MergeResult

Returns:

the result of a merge failure, null if no merge failure occurred during the revert
getFailingResult
()

Get the result of a merge failure

public List<Ref>

Returns:

the list of successfully reverted org.eclipse.jgit.lib.Ref's. Never null but maybe an empty list if no commit was successfully cherry-picked
getRevertedRefs
()

Get the list of successfully reverted org.eclipse.jgit.lib.Ref's.

public List<String>

Returns:

the unmerged paths, will be null if no merge conflicts
getUnmergedPaths
()

Get unmerged paths

public RevertCommand

Returns:

this
include
(Ref
a reference to a commit to be reverted into the current head
commit
)

Include a Ref to a commit to be reverted

public RevertCommand

Returns:

this
include
(AnyObjectId
the Id of a commit to be reverted into the current head
commit
)

Include a commit to be reverted

public RevertCommand

Returns:

this
include
(String
name of a Ref referring to the commit
name
,
AnyObjectId
the Id of a commit which is reverted into the current head
commit
)

Include a commit to be reverted

public RevertCommand

Returns:

this
setInsertChangeId
(boolean
whether to insert a change ID
insertChangeId
)

Defines whether to add a Gerrit change ID to each revert commit message.

public RevertCommand

Returns:

this
setOurCommitName
(String
the name that should be used in the "OURS" place for conflict markers
ourCommitName
)

Set the name to be used in the "OURS" place for conflict markers

public RevertCommand

Returns:

this
setProgressMonitor
(ProgressMonitor monitor)

The progress monitor associated with the revert operation.

public RevertCommand

Returns:

this
setStrategy
(MergeStrategy
The merge strategy to use for this revert command.
strategy
)

Set the merge strategy to use for this revert command

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

Field Detail

commitsback to summary
private List<Ref> commits
failingResultback to summary
private MergeResult failingResult
insertChangeIdback to summary
private boolean insertChangeId
monitorback to summary
private ProgressMonitor monitor
ourCommitNameback to summary
private String ourCommitName
revertedRefsback to summary
private List<Ref> revertedRefs
strategyback to summary
private MergeStrategy strategy
unmergedPathsback to summary
private List<String> unmergedPaths

Constructor Detail

RevertCommandback to summary
protected RevertCommand(Repository repo)

Constructor for RevertCommand.

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

calculateOurNameback to summary
private String calculateOurName(Ref headRef)
callback to summary
public RevCommit call() throws NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException, 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 revert command with all the options and parameters collected by the setter methods (e.g. include(Ref) 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:RevCommit

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

computed result

Annotations
@Override
getFailingResultback to summary
public MergeResult getFailingResult()

Get the result of a merge failure

Returns:MergeResult

the result of a merge failure, null if no merge failure occurred during the revert

getRevertedRefsback to summary
public List<Ref> getRevertedRefs()

Get the list of successfully reverted org.eclipse.jgit.lib.Ref's.

Returns:List<Ref>

the list of successfully reverted org.eclipse.jgit.lib.Ref's. Never null but maybe an empty list if no commit was successfully cherry-picked

getUnmergedPathsback to summary
public List<String> getUnmergedPaths()

Get unmerged paths

Returns:List<String>

the unmerged paths, will be null if no merge conflicts

includeback to summary
public RevertCommand include(Ref commit)

Include a Ref to a commit to be reverted

Parameters
commit:Ref

a reference to a commit to be reverted into the current head

Returns:RevertCommand

this

includeback to summary
public RevertCommand include(AnyObjectId commit)

Include a commit to be reverted

Parameters
commit:AnyObjectId

the Id of a commit to be reverted into the current head

Returns:RevertCommand

this

includeback to summary
public RevertCommand include(String name, AnyObjectId commit)

Include a commit to be reverted

Parameters
name:String

name of a Ref referring to the commit

commit:AnyObjectId

the Id of a commit which is reverted into the current head

Returns:RevertCommand

this

setInsertChangeIdback to summary
public RevertCommand setInsertChangeId(boolean insertChangeId)

Defines whether to add a Gerrit change ID to each revert commit message.

Parameters
insertChangeId:boolean

whether to insert a change ID

Returns:RevertCommand

this

Since
6.8
setOurCommitNameback to summary
public RevertCommand setOurCommitName(String ourCommitName)

Set the name to be used in the "OURS" place for conflict markers

Parameters
ourCommitName:String

the name that should be used in the "OURS" place for conflict markers

Returns:RevertCommand

this

setProgressMonitorback to summary
public RevertCommand setProgressMonitor(ProgressMonitor monitor)

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

Parameters
monitor:ProgressMonitor

a org.eclipse.jgit.lib.ProgressMonitor

Returns:RevertCommand

this

Since
4.11
See Also
NullProgressMonitor
setStrategyback to summary
public RevertCommand setStrategy(MergeStrategy strategy)

Set the merge strategy to use for this revert command

Parameters
strategy:MergeStrategy

The merge strategy to use for this revert command.

Returns:RevertCommand

this

Since
3.4