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

public Class CherryPickCommand

extends GitCommand<CherryPickResult>
Class Inheritance
Static Imports
org.eclipse.jgit.api.CherryPickCommitMessageProvider.ORIGINAL, org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH

A class used to execute a cherry-pick 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 cherry-pick

Field Summary

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

Constructor Summary

AccessConstructor and Description
protected
CherryPickCommand(Repository repo)

Constructor for CherryPickCommand

Method Summary

Modifier and TypeMethod and Description
private String
public CherryPickResult
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 RevCommit
getParentCommit(RevCommit srcCommit, RevWalk revWalk)

public CherryPickCommand

Returns:

this
include
(Ref
a reference to a commit which is cherry-picked to the current head
commit
)

Include a reference to a commit

public CherryPickCommand

Returns:

this
include
(AnyObjectId
the Id of a commit which is cherry-picked to the current head
commit
)

Include a commit

public CherryPickCommand

Returns:

this
include
(String
a name given to the commit
name
,
AnyObjectId
the Id of a commit which is cherry-picked to the current head
commit
)

Include a commit

public CherryPickCommand

Returns:

this
setCherryPickCommitMessageProvider
(CherryPickCommitMessageProvider
the commit message provider
messageProvider
)

Set a message provider for a target cherry-picked commit By default original commit message is used (see CherryPickCommitMessageProvider#ORIGINAL)

public CherryPickCommand

Returns:

this
setContentMergeStrategy
(ContentMergeStrategy
the ContentMergeStrategy to be used
strategy
)

Sets the content merge strategy to use if the merge strategy is "resolve" or "recursive".

public CherryPickCommand

Returns:

this
setMainlineParentNumber
(int
the (1-based) parent number to diff against. This allows cherry-picking of merges.
mainlineParentNumber
)

Set the (1-based) parent number to diff against

public CherryPickCommand

Returns:

this
setNoCommit
(boolean
true to cherry-pick without committing, false to commit after each pick (default)
noCommit
)

Allows cherry-picking changes without committing them.

public CherryPickCommand

Returns:

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

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

public CherryPickCommand

Returns:

this
setProgressMonitor
(ProgressMonitor monitor)

The progress monitor associated with the cherry-pick operation.

public CherryPickCommand

Returns:

this
setReflogPrefix
(String
including ":"
prefix
)

Set the prefix to use in the reflog.

public CherryPickCommand

Returns:

this
setStrategy
(MergeStrategy
The merge strategy to use during this Cherry-pick.
strategy
)

Set the MergeStrategy

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

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

Field Detail

commitsback to summary
private List<Ref> commits
contentStrategyback to summary
private ContentMergeStrategy contentStrategy
mainlineParentNumberback to summary
private Integer mainlineParentNumber
messageProviderback to summary
private CherryPickCommitMessageProvider messageProvider
monitorback to summary
private ProgressMonitor monitor
noCommitback to summary
private boolean noCommit
ourCommitNameback to summary
private String ourCommitName
reflogPrefixback to summary
private String reflogPrefix
strategyback to summary
private MergeStrategy strategy

Constructor Detail

CherryPickCommandback to summary
protected CherryPickCommand(Repository repo)

Constructor for CherryPickCommand

Parameters
repo:Repository

the org.eclipse.jgit.lib.Repository

Method Detail

calculateOurNameback to summary
private String calculateOurName(Ref headRef)
callback to summary
public CherryPickResult call() throws GitAPIException, NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException, NoHeadException

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 Cherry-Pick 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:CherryPickResult

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

computed result

Annotations
@Override
getParentCommitback to summary
private RevCommit getParentCommit(RevCommit srcCommit, RevWalk revWalk) throws MultipleParentsNotAllowedException, MissingObjectException, IOException
includeback to summary
public CherryPickCommand include(Ref commit)

Include a reference to a commit

Parameters
commit:Ref

a reference to a commit which is cherry-picked to the current head

Returns:CherryPickCommand

this

includeback to summary
public CherryPickCommand include(AnyObjectId commit)

Include a commit

Parameters
commit:AnyObjectId

the Id of a commit which is cherry-picked to the current head

Returns:CherryPickCommand

this

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

Include a commit

Parameters
name:String

a name given to the commit

commit:AnyObjectId

the Id of a commit which is cherry-picked to the current head

Returns:CherryPickCommand

this

setCherryPickCommitMessageProviderback to summary
public CherryPickCommand setCherryPickCommitMessageProvider(CherryPickCommitMessageProvider messageProvider)

Set a message provider for a target cherry-picked commit
By default original commit message is used (see CherryPickCommitMessageProvider#ORIGINAL)

Parameters
messageProvider:CherryPickCommitMessageProvider

the commit message provider

Returns:CherryPickCommand

this

Since
6.9
setContentMergeStrategyback to summary
public CherryPickCommand setContentMergeStrategy(ContentMergeStrategy strategy)

Sets the content merge strategy to use if the merge strategy is "resolve" or "recursive".

Parameters
strategy:ContentMergeStrategy

the ContentMergeStrategy to be used

Returns:CherryPickCommand

this

Since
5.12
setMainlineParentNumberback to summary
public CherryPickCommand setMainlineParentNumber(int mainlineParentNumber)

Set the (1-based) parent number to diff against

Parameters
mainlineParentNumber:int

the (1-based) parent number to diff against. This allows cherry-picking of merges.

Returns:CherryPickCommand

this

Since
3.4
setNoCommitback to summary
public CherryPickCommand setNoCommit(boolean noCommit)

Allows cherry-picking changes without committing them.

Note

The behavior of cherry-pick is undefined if you pick multiple commits or if HEAD does not match the index state before cherry-picking.

Parameters
noCommit:boolean

true to cherry-pick without committing, false to commit after each pick (default)

Returns:CherryPickCommand

this

Since
3.5
setOurCommitNameback to summary
public CherryPickCommand setOurCommitName(String ourCommitName)

Set the name that should 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:CherryPickCommand

this

setProgressMonitorback to summary
public CherryPickCommand setProgressMonitor(ProgressMonitor monitor)

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

Parameters
monitor:ProgressMonitor

a org.eclipse.jgit.lib.ProgressMonitor

Returns:CherryPickCommand

this

Since
4.11
See Also
NullProgressMonitor
setReflogPrefixback to summary
public CherryPickCommand setReflogPrefix(String prefix)

Set the prefix to use in the reflog.

This is primarily needed for implementing rebase in terms of cherry-picking

Parameters
prefix:String

including ":"

Returns:CherryPickCommand

this

Since
3.1
setStrategyback to summary
public CherryPickCommand setStrategy(MergeStrategy strategy)

Set the MergeStrategy

Parameters
strategy:MergeStrategy

The merge strategy to use during this Cherry-pick.

Returns:CherryPickCommand

this

Since
3.4
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@SuppressWarnings:nls
@Override