Package org.eclipse.jgit.api
Class CherryPickCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<CherryPickResult>
-
- org.eclipse.jgit.api.CherryPickCommand
-
- All Implemented Interfaces:
Callable<CherryPickResult>
public class CherryPickCommand extends GitCommand<CherryPickResult>
A class used to execute acherry-pick
command. It has setters for all supported options and arguments of this command and acall()
method to finally execute the command. Each instance of this class should only be used for one invocation of the command (means: one call tocall()
)- See Also:
- Git documentation about cherry-pick
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CherryPickCommand(Repository repo)
Constructor for CherryPickCommand
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CherryPickResult
call()
CherryPickCommand
include(String name, AnyObjectId commit)
Include a commitCherryPickCommand
include(AnyObjectId commit)
Include a commitCherryPickCommand
include(Ref commit)
Include a reference to a commitCherryPickCommand
setContentMergeStrategy(ContentMergeStrategy strategy)
Sets the content merge strategy to use if themerge strategy
is "resolve" or "recursive".CherryPickCommand
setMainlineParentNumber(int mainlineParentNumber)
Set the (1-based) parent number to diff againstCherryPickCommand
setNoCommit(boolean noCommit)
Allows cherry-picking changes without committing them.CherryPickCommand
setOurCommitName(String ourCommitName)
Set the name that should be used in the "OURS" place for conflict markersCherryPickCommand
setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the cherry-pick operation.CherryPickCommand
setReflogPrefix(String prefix)
Set the prefix to use in the reflog.CherryPickCommand
setStrategy(MergeStrategy strategy)
Set theMergeStrategy
String
toString()
-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
CherryPickCommand
protected CherryPickCommand(Repository repo)
Constructor for CherryPickCommand- Parameters:
repo
- theRepository
-
-
Method Detail
-
call
public CherryPickResult call() throws GitAPIException, NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException, NoHeadException
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.- Specified by:
call
in interfaceCallable<CherryPickResult>
- Specified by:
call
in classGitCommand<CherryPickResult>
- Throws:
GitAPIException
NoMessageException
UnmergedPathsException
ConcurrentRefUpdateException
WrongRepositoryStateException
NoHeadException
-
include
public CherryPickCommand include(Ref commit)
Include a reference to a commit- Parameters:
commit
- a reference to a commit which is cherry-picked to the current head- Returns:
this
-
include
public CherryPickCommand include(AnyObjectId commit)
Include a commit- Parameters:
commit
- the Id of a commit which is cherry-picked to the current head- Returns:
this
-
include
public CherryPickCommand include(String name, AnyObjectId commit)
Include a commit- Parameters:
name
- a name given to the commitcommit
- the Id of a commit which is cherry-picked to the current head- Returns:
this
-
setOurCommitName
public CherryPickCommand setOurCommitName(String ourCommitName)
Set the name that should be used in the "OURS" place for conflict markers- Parameters:
ourCommitName
- the name that should be used in the "OURS" place for conflict markers- Returns:
this
-
setReflogPrefix
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
- including ":"- Returns:
this
- Since:
- 3.1
-
setStrategy
public CherryPickCommand setStrategy(MergeStrategy strategy)
Set theMergeStrategy
- Parameters:
strategy
- The merge strategy to use during this Cherry-pick.- Returns:
this
- Since:
- 3.4
-
setContentMergeStrategy
public CherryPickCommand setContentMergeStrategy(ContentMergeStrategy strategy)
Sets the content merge strategy to use if themerge strategy
is "resolve" or "recursive".- Parameters:
strategy
- theContentMergeStrategy
to be used- Returns:
this
- Since:
- 5.12
-
setMainlineParentNumber
public CherryPickCommand setMainlineParentNumber(int mainlineParentNumber)
Set the (1-based) parent number to diff against- Parameters:
mainlineParentNumber
- the (1-based) parent number to diff against. This allows cherry-picking of merges.- Returns:
this
- Since:
- 3.4
-
setNoCommit
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
- true to cherry-pick without committing, false to commit after each pick (default)- Returns:
this
- Since:
- 3.5
-
setProgressMonitor
public CherryPickCommand setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the cherry-pick operation. By default, this is set toNullProgressMonitor
- Parameters:
monitor
- aProgressMonitor
- Returns:
this
- Since:
- 4.11
- See Also:
NullProgressMonitor
-
-