org.eclipse.jgit.api

## Class RevertCommand

- java.lang.Object
- - org.eclipse.jgit.api.GitCommand<RevCommit>
  - - org.eclipse.jgit.api.RevertCommand

All Implemented Interfaces:
  Callable<RevCommit>

    public class RevertCommand
    extends GitCommand<RevCommit>

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

### Fields inherited from class org.eclipse.jgit.api.GitCommand

`repo`

### Constructor Summary

Constructors
`protected` `RevertCommand(Repository repo)`

### Method Summary

Methods
`RevCommit` `call()` Executes the `revert` command with all the options and parameters collected by the setter methods (e.g.
`MergeResult` `getFailingResult()`
`List<Ref>` `getRevertedRefs()`
`List<String>` `getUnmergedPaths()`
`RevertCommand` `include(AnyObjectId commit)`
`RevertCommand` `include(Ref commit)`
`RevertCommand` `include(String name, AnyObjectId commit)`
`RevertCommand` `setOurCommitName(String ourCommitName)`

### Methods inherited from class org.eclipse.jgit.api.GitCommand

`checkCallable, getRepository, setCallable`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### RevertCommand

    protected RevertCommand(Repository repo)

Parameters:
  `repo` -

### Method Detail

#### call

    public RevCommit call()
                   throws NoMessageException,
                          UnmergedPathsException,
                          ConcurrentRefUpdateException,
                          WrongRepositoryStateException,
                          GitAPIException

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.

Specified by:
  `call` in interface `Callable<RevCommit>`
Specified by:
  `call` in class `GitCommand<RevCommit>`
Returns:
  on success the `RevCommit` pointed to by the new HEAD is returned. If a failure occurred during revert `null` is returned. The list of successfully reverted `Ref`'s can be obtained by calling `getRevertedRefs()`
Throws:
  `GitAPIException`
  `WrongRepositoryStateException`
  `ConcurrentRefUpdateException`
  `UnmergedPathsException`
  `NoMessageException`

#### include

    public RevertCommand include(Ref commit)

Parameters:
  `commit` - a reference to a commit which is reverted into the current head
Returns:
  `this`

#### include

    public RevertCommand include(AnyObjectId commit)

Parameters:
  `commit` - the Id of a commit which is reverted into the current head
Returns:
  `this`

#### include

    public RevertCommand include(String name,
                        AnyObjectId commit)

Parameters:
  `name` - a name given to the commit
  `commit` - the Id of a commit which is reverted into the current head
Returns:
  `this`

#### setOurCommitName

    public RevertCommand setOurCommitName(String ourCommitName)

Parameters:
  `ourCommitName` - the name that should be used in the "OURS" place for conflict markers
Returns:
  `this`

#### getRevertedRefs

    public List<Ref> getRevertedRefs()

Returns:
  the list of successfully reverted `Ref`'s. Never `null` but maybe an empty list if no commit was successfully cherry-picked

#### getFailingResult

    public MergeResult getFailingResult()

Returns:
  the result of the merge failure, `null` if no merge failure occurred during the revert

#### getUnmergedPaths

    public List<String> getUnmergedPaths()

Returns:
  the unmerged paths, will be null if no merge conflicts