ResolveMerger: Use the ObjectReader to access objects
This is necessary to ensure objects accessed by the TreeWalk come from the associated ObjectInserter when the merger is a RecursiveMerger instance and a virtual common base was constructed but not flushed. Change-Id: Iebe739d30fd868ebc4f61dbfb714673146a2c3ec
This commit is contained in:
parent
94c4d7eee8
commit
9bb891e44d
|
@ -265,7 +265,7 @@ private static PersonIdent mockAuthor(List<RevCommit> parents) {
|
|||
private DirCache dircacheFromTree(ObjectId treeId) throws IOException {
|
||||
DirCache ret = DirCache.newInCore();
|
||||
DirCacheBuilder builder = ret.builder();
|
||||
TreeWalk tw = new TreeWalk(db);
|
||||
TreeWalk tw = new TreeWalk(reader);
|
||||
tw.addTree(treeId);
|
||||
tw.setRecursive(true);
|
||||
while (tw.next()) {
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
import org.eclipse.jgit.lib.ConfigConstants;
|
||||
import org.eclipse.jgit.lib.FileMode;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectReader;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevTree;
|
||||
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
|
||||
|
@ -682,11 +683,11 @@ private MergeResult<RawText> contentMerge(CanonicalTreeParser base,
|
|||
CanonicalTreeParser ours, CanonicalTreeParser theirs)
|
||||
throws IOException {
|
||||
RawText baseText = base == null ? RawText.EMPTY_TEXT : getRawText(
|
||||
base.getEntryObjectId(), db);
|
||||
base.getEntryObjectId(), reader);
|
||||
RawText ourText = ours == null ? RawText.EMPTY_TEXT : getRawText(
|
||||
ours.getEntryObjectId(), db);
|
||||
ours.getEntryObjectId(), reader);
|
||||
RawText theirsText = theirs == null ? RawText.EMPTY_TEXT : getRawText(
|
||||
theirs.getEntryObjectId(), db);
|
||||
theirs.getEntryObjectId(), reader);
|
||||
return (mergeAlgorithm.merge(RawTextComparator.DEFAULT, baseText,
|
||||
ourText, theirsText));
|
||||
}
|
||||
|
@ -866,11 +867,11 @@ private int mergeFileModes(int modeB, int modeO, int modeT) {
|
|||
return FileMode.MISSING.getBits();
|
||||
}
|
||||
|
||||
private static RawText getRawText(ObjectId id, Repository db)
|
||||
private static RawText getRawText(ObjectId id, ObjectReader reader)
|
||||
throws IOException {
|
||||
if (id.equals(ObjectId.zeroId()))
|
||||
return new RawText(new byte[] {});
|
||||
return new RawText(db.open(id, OBJ_BLOB).getCachedBytes());
|
||||
return new RawText(reader.open(id, OBJ_BLOB).getCachedBytes());
|
||||
}
|
||||
|
||||
private static boolean nonTree(final int mode) {
|
||||
|
@ -1028,7 +1029,7 @@ protected boolean mergeTrees(AbstractTreeIterator baseTree,
|
|||
builder = dircache.builder();
|
||||
DirCacheBuildIterator buildIt = new DirCacheBuildIterator(builder);
|
||||
|
||||
tw = new NameConflictTreeWalk(db);
|
||||
tw = new NameConflictTreeWalk(reader);
|
||||
tw.addTree(baseTree);
|
||||
tw.addTree(headTree);
|
||||
tw.addTree(mergeTree);
|
||||
|
|
Loading…
Reference in New Issue