- All Implemented Interfaces:
Callable<RebaseResult>
A class used to execute a
Rebase
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Allows to configure the interactive rebase process steps and to modify commit messages.static interface
ExtendsRebaseCommand.InteractiveHandler
with an enhanced callback for editing commit messages.static enum
The available operations -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The name of the "rebase-merge" folder for interactive rebases.static final String
The name of the "stopped-sha" fileFields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RebaseCommand
(Repository repo) Constructor for RebaseCommand. -
Method Summary
Modifier and TypeMethodDescriptioncall()
Enable interactive rebaserunInteractively
(RebaseCommand.InteractiveHandler handler, boolean stopAfterRebaseInteractiveInitialization) Enable interactive rebasesetContentMergeStrategy
(ContentMergeStrategy strategy) Sets the content merge strategy to use if themerge strategy
is "resolve" or "recursive".setOperation
(RebaseCommand.Operation operation) Set the operation to execute during rebasesetPreserveMerges
(boolean preserve) Whether to preserve merges during rebasesetProgressMonitor
(ProgressMonitor monitor) Set progress monitorsetStrategy
(MergeStrategy strategy) Set theMergeStrategy
.setUpstream
(String upstream) Set the upstream branchsetUpstream
(AnyObjectId upstream) Set the upstream commitsetUpstream
(RevCommit upstream) Set upstreamRevCommit
setUpstreamName
(String upstreamName) Optionally override the name of the upstream.tryFastForward
(RevCommit newCommit) Check if we can fast-forward and returns the new head if it is possibleMethods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
REBASE_MERGE
The name of the "rebase-merge" folder for interactive rebases.- See Also:
-
STOPPED_SHA
The name of the "stopped-sha" file- See Also:
-
-
Constructor Details
-
RebaseCommand
Constructor for RebaseCommand.
- Parameters:
repo
- theRepository
-
-
Method Details
-
call
public RebaseResult call() throws GitAPIException, NoHeadException, RefNotFoundException, WrongRepositoryStateExceptionExecute the command
Executes the
Rebase
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 interfaceCallable<RebaseResult>
- Specified by:
call
in classGitCommand<RebaseResult>
- Throws:
GitAPIException
NoHeadException
RefNotFoundException
WrongRepositoryStateException
-
tryFastForward
Check if we can fast-forward and returns the new head if it is possible- Parameters:
newCommit
- aRevCommit
object to check if we can fast-forward to.- Returns:
- the new head, or null
- Throws:
IOException
- if an IO error occurredGitAPIException
- if a JGit API exception occurred
-
setUpstream
Set upstreamRevCommit
- Parameters:
upstream
- the upstream commit- Returns:
this
-
setUpstream
Set the upstream commit- Parameters:
upstream
- id of the upstream commit- Returns:
this
-
setUpstream
Set the upstream branch- Parameters:
upstream
- the name of the upstream branch- Returns:
this
- Throws:
RefNotFoundException
- ifupstream
Ref couldn't be resolved
-
setUpstreamName
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
Set the operation to execute during rebase- Parameters:
operation
- the operation to perform- Returns:
this
-
setProgressMonitor
Set progress monitor- Parameters:
monitor
- a progress monitor- Returns:
- this instance
-
runInteractively
Enable interactive rebaseDoes not stop after initialization of interactive rebase. This is equivalent to
runInteractively(handler, false)
;- Parameters:
handler
- theRebaseCommand.InteractiveHandler
to use- Returns:
- this
-
runInteractively
public RebaseCommand runInteractively(RebaseCommand.InteractiveHandler handler, boolean stopAfterRebaseInteractiveInitialization) Enable interactive rebaseIf stopAfterRebaseInteractiveInitialization is
true
the rebase stops after initialization of interactive rebase returningRebaseResult.INTERACTIVE_PREPARED_RESULT
- Parameters:
handler
- theRebaseCommand.InteractiveHandler
to usestopAfterRebaseInteractiveInitialization
- iftrue
the rebase stops after initialization- Returns:
- this instance
- Since:
- 3.2
-
setStrategy
Set theMergeStrategy
.- Parameters:
strategy
- The merge strategy to use during this rebase operation.- Returns:
this
- Since:
- 3.4
-
setContentMergeStrategy
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
-
setPreserveMerges
Whether to preserve merges during rebase- Parameters:
preserve
-true
to re-create merges during rebase. Defaults tofalse
, a flattening rebase.- Returns:
this
- Since:
- 3.5
-