Package org.eclipse.jgit.api
Class CherryPickCommand
- All Implemented Interfaces:
Callable<CherryPickResult>
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Integer
private ProgressMonitor
private boolean
private String
private String
private MergeStrategy
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CherryPickCommand
(Repository repo) Constructor for CherryPickCommand -
Method Summary
Modifier and TypeMethodDescriptionprivate String
calculateOurName
(Ref headRef) call()
private RevCommit
getParentCommit
(RevCommit srcCommit, RevWalk revWalk) include
(String name, AnyObjectId commit) Include a commitinclude
(AnyObjectId commit) Include a commitInclude a reference to a commitsetMainlineParentNumber
(int mainlineParentNumber) Set the (1-based) parent number to diff againstsetNoCommit
(boolean noCommit) Allows cherry-picking changes without committing them.setOurCommitName
(String ourCommitName) Set the name that should be used in the "OURS" place for conflict markerssetProgressMonitor
(ProgressMonitor monitor) The progress monitor associated with the cherry-pick operation.setReflogPrefix
(String prefix) Set the prefix to use in the reflog.setStrategy
(MergeStrategy strategy) Set theMergeStrategy
toString()
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
reflogPrefix
-
commits
-
ourCommitName
-
strategy
-
mainlineParentNumber
-
noCommit
private boolean noCommit -
monitor
-
-
Constructor Details
-
CherryPickCommand
Constructor for CherryPickCommand- Parameters:
repo
- theRepository
-
-
Method Details
-
call
public CherryPickResult call() throws GitAPIException, NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException, NoHeadExceptionExecute 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
-
getParentCommit
private RevCommit getParentCommit(RevCommit srcCommit, RevWalk revWalk) throws MultipleParentsNotAllowedException, MissingObjectException, IOException -
include
Include a reference to a commit- Parameters:
commit
- a reference to a commit which is cherry-picked to the current head- Returns:
this
-
include
Include a commit- Parameters:
commit
- the Id of a commit which is cherry-picked to the current head- Returns:
this
-
include
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
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
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
Set theMergeStrategy
- Parameters:
strategy
- The merge strategy to use during this Cherry-pick.- Returns:
this
- Since:
- 3.4
-
setMainlineParentNumber
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
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
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:
-
calculateOurName
-
toString
-