Package org.eclipse.jgit.api
Class RebaseCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<RebaseResult>
-
- org.eclipse.jgit.api.RebaseCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<RebaseResult>
public class RebaseCommand extends GitCommand<RebaseResult>
A class used to execute aRebase
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 Rebase
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RebaseCommand.InteractiveHandler
Allows configure rebase interactive process and modify commit messagestatic class
RebaseCommand.Operation
The available operations
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REBASE_MERGE
The name of the "rebase-merge" folder for interactive rebases.static java.lang.String
STOPPED_SHA
The name of the "stopped-sha" file-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RebaseCommand(Repository repo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RebaseResult
call()
Executes theRebase
command with all the options and parameters collected by the setter methods of this class.RebaseCommand
runInteractively(RebaseCommand.InteractiveHandler handler)
Enables interactive rebaseRebaseCommand
runInteractively(RebaseCommand.InteractiveHandler handler, boolean stopAfterRebaseInteractiveInitialization)
Enables interactive rebaseRebaseCommand
setOperation(RebaseCommand.Operation operation)
RebaseCommand
setPreserveMerges(boolean preserve)
RebaseCommand
setProgressMonitor(ProgressMonitor monitor)
RebaseCommand
setStrategy(MergeStrategy strategy)
RebaseCommand
setUpstream(java.lang.String upstream)
RebaseCommand
setUpstream(AnyObjectId upstream)
RebaseCommand
setUpstream(RevCommit upstream)
RebaseCommand
setUpstreamName(java.lang.String upstreamName)
Optionally override the name of the upstream.RevCommit
tryFastForward(RevCommit newCommit)
checks if we can fast-forward and returns the new head if it is possible-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Field Detail
-
REBASE_MERGE
public static final java.lang.String REBASE_MERGE
The name of the "rebase-merge" folder for interactive rebases.- See Also:
- Constant Field Values
-
STOPPED_SHA
public static final java.lang.String STOPPED_SHA
The name of the "stopped-sha" file- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RebaseCommand
protected RebaseCommand(Repository repo)
- Parameters:
repo
-
-
-
Method Detail
-
call
public RebaseResult call() throws GitAPIException, NoHeadException, RefNotFoundException, WrongRepositoryStateException
Executes theRebase
command with all the options and parameters collected by the setter methods 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 interfacejava.util.concurrent.Callable<RebaseResult>
- Specified by:
call
in classGitCommand<RebaseResult>
- Returns:
- an object describing the result of this command
- Throws:
GitAPIException
WrongRepositoryStateException
NoHeadException
RefNotFoundException
-
tryFastForward
public RevCommit tryFastForward(RevCommit newCommit) throws java.io.IOException, GitAPIException
checks if we can fast-forward and returns the new head if it is possible- Parameters:
newCommit
-- Returns:
- the new head, or null
- Throws:
java.io.IOException
GitAPIException
-
setUpstream
public RebaseCommand setUpstream(RevCommit upstream)
- Parameters:
upstream
- the upstream commit- Returns:
this
-
setUpstream
public RebaseCommand setUpstream(AnyObjectId upstream)
- Parameters:
upstream
- id of the upstream commit- Returns:
this
-
setUpstream
public RebaseCommand setUpstream(java.lang.String upstream) throws RefNotFoundException
- Parameters:
upstream
- the upstream branch- Returns:
this
- Throws:
RefNotFoundException
-
setUpstreamName
public RebaseCommand setUpstreamName(java.lang.String upstreamName)
Optionally override the name of the upstream. If this is used, it has to come after anysetUpstream(org.eclipse.jgit.revwalk.RevCommit)
call.- Parameters:
upstreamName
- the name which will be used to refer to upstream in conflicts- Returns:
this
-
setOperation
public RebaseCommand setOperation(RebaseCommand.Operation operation)
- Parameters:
operation
- the operation to perform- Returns:
this
-
setProgressMonitor
public RebaseCommand setProgressMonitor(ProgressMonitor monitor)
- Parameters:
monitor
- a progress monitor- Returns:
- this instance
-
runInteractively
public RebaseCommand runInteractively(RebaseCommand.InteractiveHandler handler)
Enables interactive rebaseDoes not stop after initialization of interactive rebase. This is equivalent to
runInteractively(handler, false)
;- Parameters:
handler
-- Returns:
- this
-
runInteractively
public RebaseCommand runInteractively(RebaseCommand.InteractiveHandler handler, boolean stopAfterRebaseInteractiveInitialization)
Enables interactive rebaseIf stopAfterRebaseInteractiveInitialization is
true
the rebase stops after initialization of interactive rebase returningRebaseResult.INTERACTIVE_PREPARED_RESULT
- Parameters:
handler
-stopAfterRebaseInteractiveInitialization
- iftrue
the rebase stops after initialization- Returns:
- this instance
- Since:
- 3.2
-
setStrategy
public RebaseCommand setStrategy(MergeStrategy strategy)
- Parameters:
strategy
- The merge strategy to use during this rebase operation.- Returns:
this
- Since:
- 3.4
-
setPreserveMerges
public RebaseCommand setPreserveMerges(boolean preserve)
- Parameters:
preserve
- True to re-create merges during rebase. Defaults to false, a flattening rebase.- Returns:
this
- Since:
- 3.5
-
-