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

public Class RecursiveMerger

extends ResolveMerger
Class Inheritance
Imports
java.io.IOException, java.text.MessageFormat, java.time.Instant, .ZoneOffset, java.util.ArrayList, .List, java.util.stream.Collectors, org.eclipse.jgit.dircache.DirCache, org.eclipse.jgit.errors.IncorrectObjectTypeException, .NoMergeBaseException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.CommitBuilder, .Config, .ObjectId, .ObjectInserter, .PersonIdent, .Repository, org.eclipse.jgit.revwalk.RevCommit, org.eclipse.jgit.revwalk.filter.RevFilter, org.eclipse.jgit.treewalk.AbstractTreeIterator, .EmptyTreeIterator, .WorkingTreeIterator

A three-way merger performing a content-merge if necessary across multiple bases using recursion This merger extends the resolve merger and does several things differently: - allow more than one merge base, up to a maximum - uses "Lists" instead of Arrays for chained types - recursively merges the merge bases together to compute a usable base
Since
3.0

Field Summary

Modifier and TypeField and Description
public final int
MAX_BASES

The maximum number of merge bases.

Inherited from org.eclipse.jgit.merge.ResolveMerger:
attributesNodeProvidercommitNamesdircacheenterSubtreefailingPathsinCoremergeAlgorithmmergeResultsmodifiedFilesresultTreeT_BASET_FILET_INDEXT_OURST_THEIRStwunmergedPathsworkingTreeIteratorworkTreeUpdater

Constructor Summary

AccessConstructor and Description
protected
RecursiveMerger(Repository local, boolean
a boolean.
inCore
)

Normal recursive merge when you want a choice of DirCache placement inCore

protected
RecursiveMerger(Repository local)

Normal recursive merge, implies not inCore

protected
RecursiveMerger(ObjectInserter inserter, Config
the repository configuration
config
)

Normal recursive merge, implies inCore.

Method Summary

Modifier and TypeMethod and Description
private RevCommit

Returns:

a new commit visible only within this merger's RevWalk.
createCommitForTree
(ObjectId
the tree this commit should capture
tree
,
List<RevCommit>
the list of parent commits
parents
)

Create a new commit by explicitly specifying the content tree and the parents.

private String
protected RevCommit
getBaseCommit(RevCommit
the first commit in sourceObjects.
a
,
RevCommit
the second commit in sourceObjects.
b
)

Overrides org.eclipse.jgit.merge.Merger.getBaseCommit.

Return the merge base of two commits.

protected RevCommit

Returns:

the merge base of two commits. If a criss-cross merge required a synthetic merge base this commit is visible only the merger's RevWalk and will not be in the repository.
getBaseCommit
(RevCommit
the first commit to be merged
a
,
RevCommit
the second commit to be merged
b
,
int
the callDepth when this method is called recursively
callDepth
)

Get a single base commit for two given commits.

private static PersonIdent
Inherited from org.eclipse.jgit.merge.ResolveMerger:
addDeletionaddToCheckoutfailedgetCommitNamesgetContentMergeStrategygetFailingPathsgetMergeResultsgetModifiedFilesgetResultTreeIdgetToBeCheckedOutgetUnmergedPathsmergeImplmergeTreesmergeTreeWalkprocessEntrysetAttributesNodeProvidersetCommitNamessetContentMergeStrategysetDirCachesetWorkingTreeIterator

Field Detail

MAX_BASESback to summary
public final int MAX_BASES

The maximum number of merge bases. This merge will stop when the number of merge bases exceeds this value

Constructor Detail

RecursiveMergerback to summary
protected RecursiveMerger(Repository local, boolean inCore)

Normal recursive merge when you want a choice of DirCache placement inCore

Parameters
local:Repository

a org.eclipse.jgit.lib.Repository object.

inCore:boolean

a boolean.

RecursiveMergerback to summary
protected RecursiveMerger(Repository local)

Normal recursive merge, implies not inCore

Parameters
local:Repository

a org.eclipse.jgit.lib.Repository object.

RecursiveMergerback to summary
protected RecursiveMerger(ObjectInserter inserter, Config config)

Normal recursive merge, implies inCore.

Parameters
inserter:ObjectInserter

an org.eclipse.jgit.lib.ObjectInserter object.

config:Config

the repository configuration

Since
4.8

Method Detail

createCommitForTreeback to summary
private RevCommit createCommitForTree(ObjectId tree, List<RevCommit> parents) throws IOException

Create a new commit by explicitly specifying the content tree and the parents. The commit message is not set and author/committer are set to the current user.

Parameters
tree:ObjectId

the tree this commit should capture

parents:List<RevCommit>

the list of parent commits

Returns:RevCommit

a new commit visible only within this merger's RevWalk.

Exceptions
IOException:
if an IO error occurred
failingPathsMessageback to summary
private String failingPathsMessage()
getBaseCommitback to summary
protected RevCommit getBaseCommit(RevCommit a, RevCommit b) throws IncorrectObjectTypeException, IOException

Overrides org.eclipse.jgit.merge.Merger.getBaseCommit.

Doc from org.eclipse.jgit.merge.Merger.getBaseCommit.

Return the merge base of two commits.

Get a single base commit for two given commits. If the two source commits have more than one base commit recursively merge the base commits together until you end up with a single base commit.

Parameters
a:RevCommit

the first commit in sourceObjects.

b:RevCommit

the second commit in sourceObjects.

Returns:RevCommit

the merge base of two commits

Annotations
@Override
Exceptions
IncorrectObjectTypeException:
one of the input objects is not a commit.
IOException:
objects are missing or multiple merge bases were found.
getBaseCommitback to summary
protected RevCommit getBaseCommit(RevCommit a, RevCommit b, int callDepth) throws IOException

Get a single base commit for two given commits. If the two source commits have more than one base commit recursively merge the base commits together until a virtual common base commit has been found.

Parameters
a:RevCommit

the first commit to be merged

b:RevCommit

the second commit to be merged

callDepth:int

the callDepth when this method is called recursively

Returns:RevCommit

the merge base of two commits. If a criss-cross merge required a synthetic merge base this commit is visible only the merger's RevWalk and will not be in the repository.

Exceptions
IOException:
if an IO error occurred
IncorrectObjectTypeException:
one of the input objects is not a commit.
NoMergeBaseException:
too many merge bases are found or the computation of a common merge base failed (e.g. because of a conflict).
mockAuthorback to summary
private static PersonIdent mockAuthor(List<RevCommit> parents)