Package org.eclipse.jgit.merge
Class MergeStrategy
java.lang.Object
org.eclipse.jgit.merge.MergeStrategy
- Direct Known Subclasses:
StrategyOneSided
,ThreeWayMergeStrategy
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
FieldsModifier and TypeFieldDescriptionstatic final MergeStrategy
Simple strategy that sets the output tree to the first input tree.static final ThreeWayMergeStrategy
Recursive strategy to merge paths.static final ThreeWayMergeStrategy
Simple strategy to merge paths.static final ThreeWayMergeStrategy
Simple strategy to merge paths, without simultaneous edits.private static final HashMap<String,
MergeStrategy> static final MergeStrategy
Simple strategy that sets the output tree to the second input tree. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MergeStrategy[]
get()
Get all registered strategies.static MergeStrategy
Locate a strategy by name.abstract String
getName()
Get default name of this strategy implementation.abstract Merger
newMerger
(ObjectInserter inserter, Config config) Create a new merge instance.abstract Merger
newMerger
(Repository db) Create a new merge instance.abstract Merger
newMerger
(Repository db, boolean inCore) Create a new merge instance.static void
register
(String name, MergeStrategy imp) Register a merge strategy so it can later be obtained by name.static void
register
(MergeStrategy imp) Register a merge strategy so it can later be obtained by name.
-
Field Details
-
OURS
Simple strategy that sets the output tree to the first input tree. -
THEIRS
Simple strategy that sets the output tree to the second input tree. -
SIMPLE_TWO_WAY_IN_CORE
Simple strategy to merge paths, without simultaneous edits. -
RESOLVE
Simple strategy to merge paths. It tries to merge also contents. Multiple merge bases are not supported -
RECURSIVE
Recursive strategy to merge paths. It tries to merge also contents. Multiple merge bases are supported- Since:
- 3.0
-
STRATEGIES
-
-
Constructor Details
-
MergeStrategy
public MergeStrategy()
-
-
Method Details
-
register
Register a merge strategy so it can later be obtained by name.- Parameters:
imp
- the strategy to register.- Throws:
IllegalArgumentException
- a strategy by the same name has already been registered.
-
register
Register a merge strategy so it can later be obtained by name.- Parameters:
name
- name the strategy can be looked up under.imp
- the strategy to register.- Throws:
IllegalArgumentException
- a strategy by the same name has already been registered.
-
get
Locate a strategy by name.- Parameters:
name
- name of the strategy to locate.- Returns:
- the strategy instance; null if no strategy matches the name.
-
get
Get all registered strategies.- 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.
-
getName
Get default name of this strategy implementation.- Returns:
- default name of this strategy implementation.
-
newMerger
Create a new merge instance.- Parameters:
db
- repository database the merger will read from, and eventually write results back to.- Returns:
- the new merge instance which implements this strategy.
-
newMerger
Create a new merge instance.- Parameters:
db
- repository database the merger will read from, and eventually write results back to.inCore
- 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:
- the new merge instance which implements this strategy.
-
newMerger
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
- inserter to write results back to.config
- repo config for reading diff algorithm settings.- Returns:
- the new merge instance which implements this strategy.
- Since:
- 4.8
-