|
|
@ -79,6 +79,7 @@ import org.eclipse.jgit.dircache.DirCacheBuildIterator; |
|
|
|
import org.eclipse.jgit.dircache.DirCacheBuilder; |
|
|
|
import org.eclipse.jgit.dircache.DirCacheBuilder; |
|
|
|
import org.eclipse.jgit.dircache.DirCacheCheckout; |
|
|
|
import org.eclipse.jgit.dircache.DirCacheCheckout; |
|
|
|
import org.eclipse.jgit.dircache.DirCacheEntry; |
|
|
|
import org.eclipse.jgit.dircache.DirCacheEntry; |
|
|
|
|
|
|
|
import org.eclipse.jgit.errors.BinaryBlobException; |
|
|
|
import org.eclipse.jgit.errors.CorruptObjectException; |
|
|
|
import org.eclipse.jgit.errors.CorruptObjectException; |
|
|
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException; |
|
|
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException; |
|
|
|
import org.eclipse.jgit.errors.IndexWriteException; |
|
|
|
import org.eclipse.jgit.errors.IndexWriteException; |
|
|
@ -89,9 +90,11 @@ import org.eclipse.jgit.lib.ConfigConstants; |
|
|
|
import org.eclipse.jgit.lib.FileMode; |
|
|
|
import org.eclipse.jgit.lib.FileMode; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectInserter; |
|
|
|
import org.eclipse.jgit.lib.ObjectInserter; |
|
|
|
|
|
|
|
import org.eclipse.jgit.lib.ObjectLoader; |
|
|
|
import org.eclipse.jgit.lib.ObjectReader; |
|
|
|
import org.eclipse.jgit.lib.ObjectReader; |
|
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
|
import org.eclipse.jgit.lib.Repository; |
|
|
|
import org.eclipse.jgit.revwalk.RevTree; |
|
|
|
import org.eclipse.jgit.revwalk.RevTree; |
|
|
|
|
|
|
|
import org.eclipse.jgit.storage.pack.PackConfig; |
|
|
|
import org.eclipse.jgit.treewalk.AbstractTreeIterator; |
|
|
|
import org.eclipse.jgit.treewalk.AbstractTreeIterator; |
|
|
|
import org.eclipse.jgit.treewalk.CanonicalTreeParser; |
|
|
|
import org.eclipse.jgit.treewalk.CanonicalTreeParser; |
|
|
|
import org.eclipse.jgit.treewalk.NameConflictTreeWalk; |
|
|
|
import org.eclipse.jgit.treewalk.NameConflictTreeWalk; |
|
|
@ -667,6 +670,7 @@ public class ResolveMerger extends ThreeWayMerger { |
|
|
|
// OURS or THEIRS has been deleted
|
|
|
|
// OURS or THEIRS has been deleted
|
|
|
|
if (((modeO != 0 && !tw.idEqual(T_BASE, T_OURS)) || (modeT != 0 && !tw |
|
|
|
if (((modeO != 0 && !tw.idEqual(T_BASE, T_OURS)) || (modeT != 0 && !tw |
|
|
|
.idEqual(T_BASE, T_THEIRS)))) { |
|
|
|
.idEqual(T_BASE, T_THEIRS)))) { |
|
|
|
|
|
|
|
MergeResult<RawText> result = contentMerge(base, ours, theirs); |
|
|
|
|
|
|
|
|
|
|
|
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); |
|
|
|
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); |
|
|
|
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0); |
|
|
|
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0); |
|
|
@ -687,8 +691,7 @@ public class ResolveMerger extends ThreeWayMerger { |
|
|
|
unmergedPaths.add(tw.getPathString()); |
|
|
|
unmergedPaths.add(tw.getPathString()); |
|
|
|
|
|
|
|
|
|
|
|
// generate a MergeResult for the deleted file
|
|
|
|
// generate a MergeResult for the deleted file
|
|
|
|
mergeResults.put(tw.getPathString(), |
|
|
|
mergeResults.put(tw.getPathString(), result); |
|
|
|
contentMerge(base, ours, theirs)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -709,12 +712,22 @@ public class ResolveMerger extends ThreeWayMerger { |
|
|
|
private MergeResult<RawText> contentMerge(CanonicalTreeParser base, |
|
|
|
private MergeResult<RawText> contentMerge(CanonicalTreeParser base, |
|
|
|
CanonicalTreeParser ours, CanonicalTreeParser theirs) |
|
|
|
CanonicalTreeParser ours, CanonicalTreeParser theirs) |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
|
RawText baseText = base == null ? RawText.EMPTY_TEXT : getRawText( |
|
|
|
RawText baseText; |
|
|
|
|
|
|
|
RawText ourText; |
|
|
|
|
|
|
|
RawText theirsText; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
baseText = base == null ? RawText.EMPTY_TEXT : getRawText( |
|
|
|
base.getEntryObjectId(), reader); |
|
|
|
base.getEntryObjectId(), reader); |
|
|
|
RawText ourText = ours == null ? RawText.EMPTY_TEXT : getRawText( |
|
|
|
ourText = ours == null ? RawText.EMPTY_TEXT : getRawText( |
|
|
|
ours.getEntryObjectId(), reader); |
|
|
|
ours.getEntryObjectId(), reader); |
|
|
|
RawText theirsText = theirs == null ? RawText.EMPTY_TEXT : getRawText( |
|
|
|
theirsText = theirs == null ? RawText.EMPTY_TEXT : getRawText( |
|
|
|
theirs.getEntryObjectId(), reader); |
|
|
|
theirs.getEntryObjectId(), reader); |
|
|
|
|
|
|
|
} catch (BinaryBlobException e) { |
|
|
|
|
|
|
|
MergeResult<RawText> r = new MergeResult<>(Collections.<RawText>emptyList()); |
|
|
|
|
|
|
|
r.setContainsConflicts(true); |
|
|
|
|
|
|
|
return r; |
|
|
|
|
|
|
|
} |
|
|
|
return (mergeAlgorithm.merge(RawTextComparator.DEFAULT, baseText, |
|
|
|
return (mergeAlgorithm.merge(RawTextComparator.DEFAULT, baseText, |
|
|
|
ourText, theirsText)); |
|
|
|
ourText, theirsText)); |
|
|
|
} |
|
|
|
} |
|
|
@ -891,10 +904,13 @@ public class ResolveMerger extends ThreeWayMerger { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static RawText getRawText(ObjectId id, ObjectReader reader) |
|
|
|
private static RawText getRawText(ObjectId id, ObjectReader reader) |
|
|
|
throws IOException { |
|
|
|
throws IOException, BinaryBlobException { |
|
|
|
if (id.equals(ObjectId.zeroId())) |
|
|
|
if (id.equals(ObjectId.zeroId())) |
|
|
|
return new RawText(new byte[] {}); |
|
|
|
return new RawText(new byte[] {}); |
|
|
|
return new RawText(reader.open(id, OBJ_BLOB).getCachedBytes()); |
|
|
|
|
|
|
|
|
|
|
|
ObjectLoader loader = reader.open(id, OBJ_BLOB); |
|
|
|
|
|
|
|
int threshold = PackConfig.DEFAULT_BIG_FILE_THRESHOLD; |
|
|
|
|
|
|
|
return RawText.load(loader, threshold); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static boolean nonTree(final int mode) { |
|
|
|
private static boolean nonTree(final int mode) { |
|
|
|