Class AutoMerger
An auto-merge commit is the result of merging the 2 parents of a merge commit automatically. If there are conflicts the auto-merge commit contains Git conflict markers that indicate these conflicts.
Creating auto-merge commits for octopus merges (merge commits with more than 2 parents) is not supported. In this case the auto-merge is created between the first 2 parent commits.
All created auto-merge commits are stored in the repository of their merge commit as
refs/cache-automerge/
branches. These branches serve:
- as a cache so that the each auto-merge gets computed only once
- as base for merge commits on which users can comment
The second point means that these commits are referenced from NoteDb. The consequence of this is that these refs should never be deleted.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
cacheAutomerge
(org.eclipse.jgit.lib.Config cfg) Optional<org.eclipse.jgit.transport.ReceiveCommand>
createAutoMergeCommitIfNecessary
(RepoView repoView, org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.revwalk.RevCommit maybeMergeCommit) Creates an auto merge commit for the provided commit in case it is a merge commit.static boolean
diff3ConflictView
(org.eclipse.jgit.lib.Config cfg) org.eclipse.jgit.revwalk.RevCommit
lookupFromGitOrMergeInMemory
(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk rw, InMemoryInserter ins, org.eclipse.jgit.revwalk.RevCommit merge, org.eclipse.jgit.merge.ThreeWayMergeStrategy mergeStrategy) Reads or creates an auto-merge commit of the parents of the given merge commit.
-
Field Details
-
AUTO_MERGE_MSG_PREFIX
- See Also:
-
-
Method Details
-
cacheAutomerge
public static boolean cacheAutomerge(org.eclipse.jgit.lib.Config cfg) -
diff3ConflictView
public static boolean diff3ConflictView(org.eclipse.jgit.lib.Config cfg) -
lookupFromGitOrMergeInMemory
public org.eclipse.jgit.revwalk.RevCommit lookupFromGitOrMergeInMemory(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevWalk rw, InMemoryInserter ins, org.eclipse.jgit.revwalk.RevCommit merge, org.eclipse.jgit.merge.ThreeWayMergeStrategy mergeStrategy) throws IOException Reads or creates an auto-merge commit of the parents of the given merge commit.The result is read from Git or computed in-memory and not written back to Git. This method exists for backwards compatibility only. All new changes have their auto-merge commits written transactionally when the change or patch set is created.
- Returns:
- auto-merge commit. Headers of the returned RevCommit are parsed.
- Throws:
IOException
-
createAutoMergeCommitIfNecessary
public Optional<org.eclipse.jgit.transport.ReceiveCommand> createAutoMergeCommitIfNecessary(RepoView repoView, org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.revwalk.RevCommit maybeMergeCommit) throws IOException Creates an auto merge commit for the provided commit in case it is a merge commit. To be used whenever Gerrit creates new patch sets.Callers need to include the returned
ReceiveCommand
in their ref transaction.- Returns:
- A
ReceiveCommand
wrapped in anOptional
to be used in aBatchRefUpdate
.Optional.empty()
in case we don't need an auto merge commit. - Throws:
IOException
-