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

public Class RebaseCommand

extends GitCommand<RebaseResult>
Class Inheritance
Static Imports
java.nio.charset.StandardCharsets.UTF_8

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
Git documentation about Rebase

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
RebaseCommand.InteractiveHandler

Allows to configure the interactive rebase process steps and to modify commit messages.

public static interface
RebaseCommand.InteractiveHandler2

Extends InteractiveHandler with an enhanced callback for editing commit messages.

public static enum
RebaseCommand.Operation

The available operations

private static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String
private static final String
private CommitConfig
private ContentMergeStrategy
private static final String
CURRENT_COMMIT

File containing the current commit(s) to cherry pick when --rebase-merges is used.

private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private RebaseCommand.InteractiveHandler
private boolean
private static final String
private static final String
private static final String
private ProgressMonitor
private RevCommit
private static final String
private static final String
private RebaseCommand.Operation
private static final String
private boolean
private static final String
private static final String
REBASE_APPLY

The name of the "rebase-apply" folder for non-interactive rebases.

private static final String
private static final String
REBASE_HEAD_LEGACY

Pre git 1.7.6 file name for REBASE_HEAD.

public static final String
REBASE_MERGE

The name of the "rebase-merge" folder for interactive rebases.

private final RebaseCommand.RebaseState
private static final String
private static final String
REWRITTEN

The folder containing the hashes of (potentially) rewritten commits when --rebase-merges is used.

private boolean
public static final String
STOPPED_SHA

The name of the "stopped-sha" file

private MergeStrategy
private RevCommit
private String
private final RevWalk
Inherited from org.eclipse.jgit.api.GitCommand:
repo

Constructor Summary

AccessConstructor and Description
protected
RebaseCommand(Repository repo)

Constructor for RebaseCommand.

Method Summary

Modifier and TypeMethod and Description
private RebaseResult
private void
private boolean
private List<RevCommit>
public RebaseResult
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 boolean
checkoutCommit(String headName, RevCommit commit)

private RevCommit
private void
private void
private RebaseResult
private RebaseResult
private RebaseResult
private String
composeSquashMessage(boolean isSquash, RevCommit commitToPick, String currSquashMessage, int count)

private RevCommit

Returns:

the commit if we had to do a commit, otherwise null
continueRebase
()

private RevCommit
doSquashFixup(boolean isSquash, RevCommit commitToPick, boolean isLast, File messageFixup, File messageSquash)

private String
editCommitMessage(boolean[] doChangeId, String message, CommitConfig.CleanupMode mode, char commentChar)

private RebaseResult
finishRebase(RevCommit finalHead, boolean lastStepIsForward)

private Ref
private static String
private List<RevCommit>
getNewParents(RevCommit commitToPick)

private static String
getOrdinal(int count)

private ObjectId
private String
private RebaseResult
private void
initializeSquashFixupFile(String messageFile, String fullMessage)

private boolean
private PersonIdent
pack-priv PersonIdent
parseAuthor(byte[] raw)

pack-priv static int

Returns:

the count of squashed messages in the given string
parseSquashFixupSequenceCount
(String
the squashed commit message to be parsed
currSquashMessage
)

Parse the count from squashed commit messages

private void
popSteps(int
number of steps to remove
numSteps
)

Removes the number of lines given in the parameter from the git-rebase-todo file but preserves comments and other lines that can not be parsed as steps

private RebaseResult
processStep(RebaseTodoLine step, boolean shouldPick)

private String
replaceCommentChar(String message, char oldChar, char newChar)

private void
public RebaseCommand

Returns:

this
runInteractively
(RebaseCommand.InteractiveHandler handler)

Enable interactive rebase

Does not stop after initialization of interactive rebase.

public RebaseCommand

Returns:

this instance
runInteractively
(RebaseCommand.InteractiveHandler handler, final boolean
if true the rebase stops after initialization
stopAfterRebaseInteractiveInitialization
)

Enable interactive rebase

If stopAfterRebaseInteractiveInitialization is true the rebase stops after initialization of interactive rebase returning org.eclipse.jgit.api.RebaseResult#INTERACTIVE_PREPARED_RESULT

public RebaseCommand

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 RebaseCommand

Returns:

this
setOperation
(RebaseCommand.Operation
the operation to perform
operation
)

Set the operation to execute during rebase

public RebaseCommand

Returns:

this
setPreserveMerges
(boolean
true to re-create merges during rebase. Defaults to false, a flattening rebase.
preserve
)

Whether to preserve merges during rebase

public RebaseCommand

Returns:

this instance
setProgressMonitor
(ProgressMonitor
a progress monitor
monitor
)

Set progress monitor

public RebaseCommand

Returns:

this
setStrategy
(MergeStrategy
The merge strategy to use during this rebase operation.
strategy
)

Set the MergeStrategy.

public RebaseCommand

Returns:

this
setUpstream
(RevCommit
the upstream commit
upstream
)

Set upstream RevCommit

public RebaseCommand

Returns:

this
setUpstream
(AnyObjectId
id of the upstream commit
upstream
)

Set the upstream commit

public RebaseCommand

Returns:

this
setUpstream
(String
the name of the upstream branch
upstream
)

Set the upstream branch

public RebaseCommand

Returns:

this
setUpstreamName
(String
the name which will be used to refer to upstream in conflicts
upstreamName
)

Optionally override the name of the upstream.

private RevCommit
squashIntoPrevious(boolean sequenceContainsSquash, boolean isLast)

private RebaseResult
stop(RevCommit commitToPick, RebaseResult.Status status)

pack-priv String
public RevCommit

Returns:

the new head, or null
tryFastForward
(RevCommit
a org.eclipse.jgit.revwalk.RevCommit object to check if we can fast-forward to.
newCommit
)

Check if we can fast-forward and returns the new head if it is possible

private RevCommit
tryFastForward(String headName, RevCommit oldCommit, RevCommit newCommit)

private void
updateHead(String headName, RevCommit aNewHead, RevCommit onto)

private void
updateStashRef(ObjectId commitId, PersonIdent refLogIdent, String refLogMessage)

private void
private void
writeMergeInfo(RevCommit commitToPick, List<RevCommit> newParents)

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