public class MergeCommand extends GitCommand<MergeResult>
Merge
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()
)Modifier and Type | Class and Description |
---|---|
static class |
MergeCommand.FastForwardMode
The modes available for fast forward merges corresponding to the
--ff , --no-ff and --ff-only
options under branch.<name>.mergeoptions . |
repo
Modifier | Constructor and Description |
---|---|
protected |
MergeCommand(Repository repo)
Constructor for MergeCommand.
|
Modifier and Type | Method and Description |
---|---|
MergeResult |
call() |
MergeCommand |
include(AnyObjectId aCommit)
Id of a commit which is to be merged with the current head
|
MergeCommand |
include(Ref aCommit)
Reference to a commit to be merged with the current head
|
MergeCommand |
include(String name,
AnyObjectId aCommit)
Include a commit
|
MergeCommand |
setCommit(boolean commit)
Controls whether the merge command should automatically commit after a
successful merge
|
MergeCommand |
setFastForward(MergeCommand.FastForwardMode fastForwardMode)
Sets the fast forward mode.
|
MergeCommand |
setInsertChangeId(boolean insertChangeId)
If set to true a change id will be inserted into the commit message
An existing change id is not replaced.
|
MergeCommand |
setMessage(String message)
Set the commit message to be used for the merge commit (in case one is
created)
|
MergeCommand |
setProgressMonitor(ProgressMonitor monitor)
The progress monitor associated with the diff operation.
|
MergeCommand |
setSquash(boolean squash)
If
true , will prepare the next commit in working tree and
index as if a real merge happened, but do not make the commit or move the
HEAD. |
MergeCommand |
setStrategy(MergeStrategy mergeStrategy)
Set merge strategy
|
checkCallable, getRepository, setCallable
protected MergeCommand(Repository repo)
repo
- the Repository
public MergeResult call() throws GitAPIException, NoHeadException, ConcurrentRefUpdateException, CheckoutConflictException, InvalidMergeHeadsException, WrongRepositoryStateException, NoMessageException
Execute the command
Execute the Merge
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.
call
in interface Callable<MergeResult>
call
in class GitCommand<MergeResult>
GitAPIException
NoHeadException
ConcurrentRefUpdateException
CheckoutConflictException
InvalidMergeHeadsException
WrongRepositoryStateException
NoMessageException
public MergeCommand setStrategy(MergeStrategy mergeStrategy)
mergeStrategy
- the MergeStrategy
to be usedthis
public MergeCommand include(Ref aCommit)
aCommit
- a reference to a commit which is merged with the current headthis
public MergeCommand include(AnyObjectId aCommit)
aCommit
- the Id of a commit which is merged with the current headthis
public MergeCommand include(String name, AnyObjectId aCommit)
name
- a name of a Ref
pointing to the commitaCommit
- the Id of a commit which is merged with the current headthis
public MergeCommand setSquash(boolean squash)
true
, will prepare the next commit in working tree and
index as if a real merge happened, but do not make the commit or move the
HEAD. Otherwise, perform the merge and commit the result.
In case the merge was successful but this flag was set to
true
a MergeResult
with status
MergeResult.MergeStatus.MERGED_SQUASHED
or
MergeResult.MergeStatus.FAST_FORWARD_SQUASHED
is returned.
squash
- whether to squash commits or notthis
public MergeCommand setFastForward(@Nullable MergeCommand.FastForwardMode fastForwardMode)
fastForwardMode
- corresponds to the --ff/--no-ff/--ff-only options. If
null
use the value of the merge.ff
option
configured in git config. If this option is not configured
--ff is the built-in default.this
public MergeCommand setCommit(boolean commit)
commit
- true
if this command should commit (this is the
default behavior). false
if this command should
not commit. In case the merge was successful but this flag was
set to false
a
MergeResult
with type
MergeResult
with status
MergeResult.MergeStatus.MERGED_NOT_COMMITTED
is returnedthis
public MergeCommand setMessage(String message)
message
- the message to be used for the merge committhis
public MergeCommand setInsertChangeId(boolean insertChangeId)
insertChangeId
- whether to insert a change idthis
public MergeCommand setProgressMonitor(ProgressMonitor monitor)
NullProgressMonitor
monitor
- A progress monitorNullProgressMonitor
Copyright © 2018 Eclipse JGit Project. All rights reserved.