Top Description Fields Constructors Methods
org.eclipse.jgit.merge

public abstract Class MergeStrategy

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.merge.StrategyOneSided, org.eclipse.jgit.merge.ThreeWayMergeStrategy
Imports
java.text.MessageFormat, java.util.HashMap, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.Config, .ObjectInserter, .Repository

A method of combining two or more trees together to form an output tree.

Different strategies may employ different techniques for deciding which paths (and ObjectIds) to carry from the input trees into the final output tree.

Field Summary

Modifier and TypeField and Description
public static final MergeStrategy
OURS

Simple strategy that sets the output tree to the first input tree.

public static final ThreeWayMergeStrategy
RECURSIVE

Recursive strategy to merge paths.

public static final ThreeWayMergeStrategy
RESOLVE

Simple strategy to merge paths.

public static final ThreeWayMergeStrategy
SIMPLE_TWO_WAY_IN_CORE

Simple strategy to merge paths, without simultaneous edits.

private static final HashMap<String, MergeStrategy>
public static final MergeStrategy
THEIRS

Simple strategy that sets the output tree to the second input tree.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static synchronized MergeStrategy

Returns:

the strategy instance; null if no strategy matches the name.
get
(String
name of the strategy to locate.
name
)

Locate a strategy by name.

public static synchronized MergeStrategy[]

Returns:

the registered strategy instances. No inherit order is returned; the caller may modify (and/or sort) the returned array if necessary to obtain a reasonable ordering.
get
()

Get all registered strategies.

public abstract String

Returns:

default name of this strategy implementation.
getName
()

Get default name of this strategy implementation.

public abstract Merger

Returns:

the new merge instance which implements this strategy.
newMerger
(Repository
repository database the merger will read from, and eventually write results back to.
db
)

Create a new merge instance.

public abstract Merger

Returns:

the new merge instance which implements this strategy.
newMerger
(Repository
repository database the merger will read from, and eventually write results back to.
db
,
boolean
the merge will happen in memory, working folder will not be modified, in case of a non-trivial merge that requires manual resolution, the merger will fail.
inCore
)

Create a new merge instance.

public abstract Merger

Returns:

the new merge instance which implements this strategy.
newMerger
(ObjectInserter
inserter to write results back to.
inserter
,
Config
repo config for reading diff algorithm settings.
config
)

Create a new merge instance.

public static void
register(MergeStrategy
the strategy to register.
imp
)

Register a merge strategy so it can later be obtained by name.

public static synchronized void
register(final String
name the strategy can be looked up under.
name
,
final MergeStrategy
the strategy to register.
imp
)

Register a merge strategy so it can later be obtained by name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

OURSback to summary
public static final MergeStrategy OURS

Simple strategy that sets the output tree to the first input tree.

RECURSIVEback to summary
public static final ThreeWayMergeStrategy RECURSIVE

Recursive strategy to merge paths. It tries to merge also contents. Multiple merge bases are supported

Since
3.0
RESOLVEback to summary
public static final ThreeWayMergeStrategy RESOLVE

Simple strategy to merge paths. It tries to merge also contents. Multiple merge bases are not supported

SIMPLE_TWO_WAY_IN_COREback to summary
public static final ThreeWayMergeStrategy SIMPLE_TWO_WAY_IN_CORE

Simple strategy to merge paths, without simultaneous edits.

STRATEGIESback to summary
private static final HashMap<String, MergeStrategy> STRATEGIES
THEIRSback to summary
public static final MergeStrategy THEIRS

Simple strategy that sets the output tree to the second input tree.

Constructor Detail

MergeStrategyback to summary
public MergeStrategy()

Method Detail

getback to summary
public static synchronized MergeStrategy get(String name)

Locate a strategy by name.

Parameters
name:String

name of the strategy to locate.

Returns:MergeStrategy

the strategy instance; null if no strategy matches the name.

getback to summary
public static synchronized MergeStrategy[] get()

Get all registered strategies.

Returns:MergeStrategy[]

the registered strategy instances. No inherit order is returned; the caller may modify (and/or sort) the returned array if necessary to obtain a reasonable ordering.

getNameback to summary
public abstract String getName()

Get default name of this strategy implementation.

Returns:String

default name of this strategy implementation.

newMergerback to summary
public abstract Merger newMerger(Repository db)

Create a new merge instance.

Parameters
db:Repository

repository database the merger will read from, and eventually write results back to.

Returns:Merger

the new merge instance which implements this strategy.

newMergerback to summary
public abstract Merger newMerger(Repository db, boolean inCore)

Create a new merge instance.

Parameters
db:Repository

repository database the merger will read from, and eventually write results back to.

inCore:boolean

the merge will happen in memory, working folder will not be modified, in case of a non-trivial merge that requires manual resolution, the merger will fail.

Returns:Merger

the new merge instance which implements this strategy.

newMergerback to summary
public abstract Merger newMerger(ObjectInserter inserter, Config config)

Create a new merge instance.

The merge will happen in memory, working folder will not be modified, in case of a non-trivial merge that requires manual resolution, the merger will fail.

Parameters
inserter:ObjectInserter

inserter to write results back to.

config:Config

repo config for reading diff algorithm settings.

Returns:Merger

the new merge instance which implements this strategy.

Since
4.8
registerback to summary
public static void register(MergeStrategy imp)

Register a merge strategy so it can later be obtained by name.

Parameters
imp:MergeStrategy

the strategy to register.

Exceptions
IllegalArgumentException:
a strategy by the same name has already been registered.
registerback to summary
public static synchronized void register(final String name, final MergeStrategy imp)

Register a merge strategy so it can later be obtained by name.

Parameters
name:String

name the strategy can be looked up under.

imp:MergeStrategy

the strategy to register.

Exceptions
IllegalArgumentException:
a strategy by the same name has already been registered.