Top Description Inners Fields Constructors Methods
org.eclipse.jgit.api

public Class MergeResult

extends Object
Class Inheritance
Imports
java.text.MessageFormat, java.util.HashMap, .List, .Map, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.ObjectId, org.eclipse.jgit.merge.MergeChunk, .MergeChunk.ConflictState, .MergeStrategy, .ResolveMerger.MergeFailureReason

Encapsulates the result of a org.eclipse.jgit.api.MergeCommand.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
MergeResult.MergeStatus

The status the merge resulted in.

Field Summary

Modifier and TypeField and Description
private ObjectId
private List<String>
private Map<String, int[][]>
private String
private Map<String, ResolveMerger.MergeFailureReason>
private ObjectId[]
private MergeResult.MergeStatus
private MergeStrategy
private ObjectId

Constructor Summary

AccessConstructor and Description
public
MergeResult(ObjectId
the object the head points at after the merge
newHead
,
ObjectId
the common base which was used to produce a content-merge. May be null if the merge-result was produced without computing a common base
base
,
ObjectId[]
all the commits which have been merged together
mergedCommits
,
MergeResult.MergeStatus
the status the merge resulted in
mergeStatus
,
MergeStrategy mergeStrategy, Map<String, MergeResult<?>> lowLevelResults)

Constructor for MergeResult.

public
MergeResult(ObjectId
the object the head points at after the merge
newHead
,
ObjectId
the common base which was used to produce a content-merge. May be null if the merge-result was produced without computing a common base
base
,
ObjectId[]
all the commits which have been merged together
mergedCommits
,
MergeResult.MergeStatus
the status the merge resulted in
mergeStatus
,
MergeStrategy mergeStrategy, Map<String, MergeResult<?>> lowLevelResults, String
a user friendly description of the merge result
description
)

Constructor for MergeResult.

public
MergeResult(ObjectId
the object the head points at after the merge
newHead
,
ObjectId
the common base which was used to produce a content-merge. May be null if the merge-result was produced without computing a common base
base
,
ObjectId[]
all the commits which have been merged together
mergedCommits
,
MergeResult.MergeStatus
the status the merge resulted in
mergeStatus
,
MergeStrategy mergeStrategy, Map<String, MergeResult<?>> lowLevelResults, Map<String, ResolveMerger.MergeFailureReason>
list of paths causing this merge to fail as returned by org.eclipse.jgit.merge.ResolveMerger#getFailingPaths()
failingPaths
,
String
a user friendly description of the merge result
description
)

Constructor for MergeResult.

public
MergeResult(List<String>
the conflicting files
checkoutConflicts
)

Creates a new result that represents a checkout conflict before the operation even started for real.

Method Summary

Modifier and TypeMethod and Description
public void
addConflict(String
path of the file to add a conflict for
path
,
int[][]
the conflicts to set
conflictingRanges
)

Add a conflict

public void
addConflict(String
path of the file to add a conflict for
path
,
MergeResult<?> lowLevelResult)

Add a conflict

public ObjectId

Returns:

base the common base which was used to produce a content-merge. May be null if the merge-result was produced without computing a common base
getBase
()

Get the common base

public List<String>

Returns:

the list of files that caused the checkout conflict.
getCheckoutConflicts
()

Returns a list of paths that cause a checkout conflict.

public Map<String, int[][]>

Returns:

the conflicts or null if no conflict occurred
getConflicts
()

Returns information about the conflicts which occurred during a org.eclipse.jgit.api.MergeCommand.

public Map<String, ResolveMerger.MergeFailureReason>

Returns:

the list of paths causing this merge to fail or null if no failure occurred
getFailingPaths
()

Returns a list of paths causing this merge to fail as returned by org.eclipse.jgit.merge.ResolveMerger#getFailingPaths()

public ObjectId[]

Returns:

all the commits which have been merged together
getMergedCommits
()

Get the commits which have been merged

public MergeResult.MergeStatus

Returns:

the status the merge resulted in
getMergeStatus
()

Get the merge status

public ObjectId

Returns:

the object the head points at after the merge
getNewHead
()

Get the object the head points at after the merge

public void
setConflicts(Map<String, int[][]>
the conflicts to set
conflicts
)

Set conflicts

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

baseback to summary
private ObjectId base
checkoutConflictsback to summary
private List<String> checkoutConflicts
conflictsback to summary
private Map<String, int[][]> conflicts
descriptionback to summary
private String description
failingPathsback to summary
private Map<String, ResolveMerger.MergeFailureReason> failingPaths
mergedCommitsback to summary
private ObjectId[] mergedCommits
mergeStatusback to summary
private MergeResult.MergeStatus mergeStatus
mergeStrategyback to summary
private MergeStrategy mergeStrategy
newHeadback to summary
private ObjectId newHead

Constructor Detail

MergeResultback to summary
public MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, Map<String, MergeResult<?>> lowLevelResults)

Constructor for MergeResult.

Parameters
newHead:ObjectId

the object the head points at after the merge

base:ObjectId

the common base which was used to produce a content-merge. May be null if the merge-result was produced without computing a common base

mergedCommits:ObjectId[]

all the commits which have been merged together

mergeStatus:MergeResult.MergeStatus

the status the merge resulted in

mergeStrategy:MergeStrategy

the used org.eclipse.jgit.merge.MergeStrategy

lowLevelResults:Map<String, MergeResult<?>>

merge results as returned by org.eclipse.jgit.merge.ResolveMerger#getMergeResults()

Since
2.0
MergeResultback to summary
public MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, Map<String, MergeResult<?>> lowLevelResults, String description)

Constructor for MergeResult.

Parameters
newHead:ObjectId

the object the head points at after the merge

base:ObjectId

the common base which was used to produce a content-merge. May be null if the merge-result was produced without computing a common base

mergedCommits:ObjectId[]

all the commits which have been merged together

mergeStatus:MergeResult.MergeStatus

the status the merge resulted in

mergeStrategy:MergeStrategy

the used org.eclipse.jgit.merge.MergeStrategy

lowLevelResults:Map<String, MergeResult<?>>

merge results as returned by org.eclipse.jgit.merge.ResolveMerger#getMergeResults()

description:String

a user friendly description of the merge result

MergeResultback to summary
public MergeResult(ObjectId newHead, ObjectId base, ObjectId[] mergedCommits, MergeResult.MergeStatus mergeStatus, MergeStrategy mergeStrategy, Map<String, MergeResult<?>> lowLevelResults, Map<String, ResolveMerger.MergeFailureReason> failingPaths, String description)

Constructor for MergeResult.

Parameters
newHead:ObjectId

the object the head points at after the merge

base:ObjectId

the common base which was used to produce a content-merge. May be null if the merge-result was produced without computing a common base

mergedCommits:ObjectId[]

all the commits which have been merged together

mergeStatus:MergeResult.MergeStatus

the status the merge resulted in

mergeStrategy:MergeStrategy

the used org.eclipse.jgit.merge.MergeStrategy

lowLevelResults:Map<String, MergeResult<?>>

merge results as returned by org.eclipse.jgit.merge.ResolveMerger#getMergeResults()

failingPaths:Map<String, ResolveMerger.MergeFailureReason>

list of paths causing this merge to fail as returned by org.eclipse.jgit.merge.ResolveMerger#getFailingPaths()

description:String

a user friendly description of the merge result

MergeResultback to summary
public MergeResult(List<String> checkoutConflicts)

Creates a new result that represents a checkout conflict before the operation even started for real.

Parameters
checkoutConflicts:List<String>

the conflicting files

Method Detail

addConflictback to summary
public void addConflict(String path, int[][] conflictingRanges)

Add a conflict

Parameters
path:String

path of the file to add a conflict for

conflictingRanges:int[][]

the conflicts to set

addConflictback to summary
public void addConflict(String path, MergeResult<?> lowLevelResult)

Add a conflict

Parameters
path:String

path of the file to add a conflict for

lowLevelResult:MergeResult<?>

a org.eclipse.jgit.merge.MergeResult

getBaseback to summary
public ObjectId getBase()

Get the common base

Returns:ObjectId

base the common base which was used to produce a content-merge. May be null if the merge-result was produced without computing a common base

getCheckoutConflictsback to summary
public List<String> getCheckoutConflicts()

Returns a list of paths that cause a checkout conflict. These paths prevent the operation from even starting.

Returns:List<String>

the list of files that caused the checkout conflict.

getConflictsback to summary
public Map<String, int[][]> getConflicts()

Returns information about the conflicts which occurred during a org.eclipse.jgit.api.MergeCommand. The returned value maps the path of a conflicting file to a two-dimensional int-array of line-numbers telling where in the file conflict markers for which merged commit can be found.

If the returned value contains a mapping "path"->[x][y]=z then this means

  • the file with path "path" contains conflicts
  • if y < "number of merged commits": for conflict number x in this file the chunk which was copied from commit number y starts on line number z. All numberings and line numbers start with 0.
  • if y == "number of merged commits": the first non-conflicting line after conflict number x starts at line number z

Example code how to parse this data:

MergeResult m=...;
Map<String, int[][]> allConflicts = m.getConflicts();
for (String path : allConflicts.keySet()) {
	int[][] c = allConflicts.get(path);
	System.out.println("Conflicts in file " + path);
	for (int i = 0; i < c.length; ++i) {
		System.out.println("  Conflict #" + i);
		for (int j = 0; j < (c[i].length) - 1; ++j) {
			if (c[i][j] >= 0)
				System.out.println("    Chunk for "
						+ m.getMergedCommits()[j] + " starts on line #"
						+ c[i][j]);
		}
	}
}
Returns:Map<String, int[][]>

the conflicts or null if no conflict occurred

getFailingPathsback to summary
public Map<String, ResolveMerger.MergeFailureReason> getFailingPaths()

Returns a list of paths causing this merge to fail as returned by org.eclipse.jgit.merge.ResolveMerger#getFailingPaths()

Returns:Map<String, ResolveMerger.MergeFailureReason>

the list of paths causing this merge to fail or null if no failure occurred

getMergedCommitsback to summary
public ObjectId[] getMergedCommits()

Get the commits which have been merged

Returns:ObjectId[]

all the commits which have been merged together

getMergeStatusback to summary
public MergeResult.MergeStatus getMergeStatus()

Get the merge status

Returns:MergeResult.MergeStatus

the status the merge resulted in

getNewHeadback to summary
public ObjectId getNewHead()

Get the object the head points at after the merge

Returns:ObjectId

the object the head points at after the merge

setConflictsback to summary
public void setConflicts(Map<String, int[][]> conflicts)

Set conflicts

Parameters
conflicts:Map<String, int[][]>

the conflicts to set

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@SuppressWarnings:nls
@Override
org.eclipse.jgit.api back to summary

public sealed Enum MergeResult.MergeStatus

extends Enum<MergeResult.MergeStatus>
Class Inheritance

The status the merge resulted in.

Field Summary

Modifier and TypeField and Description
public static final MergeResult.MergeStatus
ABORTED

Merge was aborted

public static final MergeResult.MergeStatus
ALREADY_UP_TO_DATE

Already up to date, merge was a no-op

public static final MergeResult.MergeStatus
CHECKOUT_CONFLICT

Status representing a checkout conflict, meaning that nothing could be merged, as the pre-scan for the trees already failed for certain files (i.e. local modifications prevent checkout of files).

public static final MergeResult.MergeStatus
CONFLICTING

Merge raised conflicts to be resolved

public static final MergeResult.MergeStatus
FAILED

Merge failed

public static final MergeResult.MergeStatus
FAST_FORWARD

Merge is a fast-forward

public static final MergeResult.MergeStatus
FAST_FORWARD_SQUASHED

Merge is a fast-forward, squashed

public static final MergeResult.MergeStatus
MERGED

Merged

public static final MergeResult.MergeStatus
MERGED_NOT_COMMITTED

Merged, not committed

public static final MergeResult.MergeStatus
MERGED_SQUASHED

Merged, squashed, not updating HEAD

public static final MergeResult.MergeStatus
MERGED_SQUASHED_NOT_COMMITTED

Merged, squashed, not committed

public static final MergeResult.MergeStatus
NOT_SUPPORTED

Not yet supported

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public abstract boolean

Returns:

whether the status indicates a successful result
isSuccessful
()

Whether the merge was successful

public static MergeResult.MergeStatus
public static MergeResult.MergeStatus[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ABORTEDback to summary
public static final MergeResult.MergeStatus ABORTED

Merge was aborted

Since
2.2
ALREADY_UP_TO_DATEback to summary
public static final MergeResult.MergeStatus ALREADY_UP_TO_DATE

Already up to date, merge was a no-op

CHECKOUT_CONFLICTback to summary
public static final MergeResult.MergeStatus CHECKOUT_CONFLICT

Status representing a checkout conflict, meaning that nothing could be merged, as the pre-scan for the trees already failed for certain files (i.e. local modifications prevent checkout of files).

CONFLICTINGback to summary
public static final MergeResult.MergeStatus CONFLICTING

Merge raised conflicts to be resolved

FAILEDback to summary
public static final MergeResult.MergeStatus FAILED

Merge failed

FAST_FORWARDback to summary
public static final MergeResult.MergeStatus FAST_FORWARD

Merge is a fast-forward

FAST_FORWARD_SQUASHEDback to summary
public static final MergeResult.MergeStatus FAST_FORWARD_SQUASHED

Merge is a fast-forward, squashed

Since
2.0
MERGEDback to summary
public static final MergeResult.MergeStatus MERGED

Merged

MERGED_NOT_COMMITTEDback to summary
public static final MergeResult.MergeStatus MERGED_NOT_COMMITTED

Merged, not committed

Since
3.0
MERGED_SQUASHEDback to summary
public static final MergeResult.MergeStatus MERGED_SQUASHED

Merged, squashed, not updating HEAD

Since
2.0
MERGED_SQUASHED_NOT_COMMITTEDback to summary
public static final MergeResult.MergeStatus MERGED_SQUASHED_NOT_COMMITTED

Merged, squashed, not committed

Since
3.0
NOT_SUPPORTEDback to summary
public static final MergeResult.MergeStatus NOT_SUPPORTED

Not yet supported

Constructor Detail

MergeStatusback to summary
private MergeStatus()

Method Detail

isSuccessfulback to summary
public abstract boolean isSuccessful()

Whether the merge was successful

Returns:boolean

whether the status indicates a successful result

valueOfback to summary
public static MergeResult.MergeStatus valueOf(String name)
valuesback to summary
public static MergeResult.MergeStatus[] values()