Package org.eclipse.jgit.merge
Class ThreeWayMerger
- java.lang.Object
-
- org.eclipse.jgit.merge.Merger
-
- org.eclipse.jgit.merge.ThreeWayMerger
-
- Direct Known Subclasses:
ResolveMerger
public abstract class ThreeWayMerger extends Merger
A merge of 2 trees, using a common base ancestor tree.
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.merge.Merger
db, monitor, reader, sourceCommits, sourceObjects, sourceTrees, walk
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ThreeWayMerger(ObjectInserter inserter)
Create a new in-core merge instance from an inserter.protected
ThreeWayMerger(Repository local)
Create a new merge instance for a repository.protected
ThreeWayMerger(Repository local, boolean inCore)
Create a new merge instance for a repository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectId
getBaseCommitId()
Get the ID of the commit that was used as merge base for mergingboolean
merge(AnyObjectId... tips)
Merge together two or more tree-ish objects.protected AbstractTreeIterator
mergeBase()
Create an iterator to walk the merge base.void
setBase(AnyObjectId id)
Set the common ancestor tree.-
Methods inherited from class org.eclipse.jgit.merge.Merger
getBaseCommit, getObjectInserter, getRepository, getResultTreeId, merge, mergeImpl, nonNullRepo, openTree, setObjectInserter, setProgressMonitor
-
-
-
-
Constructor Detail
-
ThreeWayMerger
protected ThreeWayMerger(Repository local)
Create a new merge instance for a repository.- Parameters:
local
- the repository this merger will read and write data on.
-
ThreeWayMerger
protected ThreeWayMerger(Repository local, boolean inCore)
Create a new merge instance for a repository.- Parameters:
local
- the repository this merger will read and write data on.inCore
- perform the merge in core with no working folder involved
-
ThreeWayMerger
protected ThreeWayMerger(ObjectInserter inserter)
Create a new in-core merge instance from an inserter.- Parameters:
inserter
- the inserter to write objects to.- Since:
- 4.8
-
-
Method Detail
-
setBase
public void setBase(AnyObjectId id) throws MissingObjectException, IncorrectObjectTypeException, IOException
Set the common ancestor tree.- Parameters:
id
- common base treeish; null to automatically compute the common base from the input commits duringmerge(AnyObjectId...)
.- Throws:
IncorrectObjectTypeException
- the object is not a treeish.MissingObjectException
- the object does not exist.IOException
- the object could not be read.
-
merge
public boolean merge(AnyObjectId... tips) throws IOException
Merge together two or more tree-ish objects.Any tree-ish may be supplied as inputs. Commits and/or tags pointing at trees or commits may be passed as input objects.
- Overrides:
merge
in classMerger
- Parameters:
tips
- source trees to be combined together. The merge base is not included in this set.- Returns:
- true if the merge was completed without conflicts; false if the merge strategy cannot handle this merge or there were conflicts preventing it from automatically resolving all paths.
- Throws:
IncorrectObjectTypeException
- one of the input objects is not a commit, but the strategy requires it to be a commit.IOException
- one or more sources could not be read, or outputs could not be written to the Repository.
-
getBaseCommitId
public ObjectId getBaseCommitId()
Get the ID of the commit that was used as merge base for merging- Specified by:
getBaseCommitId
in classMerger
- Returns:
- the ID of the commit that was used as merge base for merging, or null if no merge base was used or it was set manually
-
mergeBase
protected AbstractTreeIterator mergeBase() throws IOException
Create an iterator to walk the merge base.- Returns:
- an iterator over the caller-specified merge base, or the natural merge base of the two input commits.
- Throws:
IOException
-
-