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 {
|
private DirCache dircacheFromTree(ObjectId treeId) throws IOException {
|
||||||
DirCache ret = DirCache.newInCore();
|
DirCache ret = DirCache.newInCore();
|
||||||
DirCacheBuilder builder = ret.builder();
|
DirCacheBuilder builder = ret.builder();
|
||||||
TreeWalk tw = new TreeWalk(db);
|
TreeWalk tw = new TreeWalk(reader);
|
||||||
tw.addTree(treeId);
|
tw.addTree(treeId);
|
||||||
tw.setRecursive(true);
|
tw.setRecursive(true);
|
||||||
while (tw.next()) {
|
while (tw.next()) {
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
import org.eclipse.jgit.lib.ConfigConstants;
|
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.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.treewalk.AbstractTreeIterator;
|
import org.eclipse.jgit.treewalk.AbstractTreeIterator;
|
||||||
|
@ -682,11 +683,11 @@ 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 = base == null ? RawText.EMPTY_TEXT : getRawText(
|
||||||
base.getEntryObjectId(), db);
|
base.getEntryObjectId(), reader);
|
||||||
RawText ourText = ours == null ? RawText.EMPTY_TEXT : getRawText(
|
RawText ourText = ours == null ? RawText.EMPTY_TEXT : getRawText(
|
||||||
ours.getEntryObjectId(), db);
|
ours.getEntryObjectId(), reader);
|
||||||
RawText theirsText = theirs == null ? RawText.EMPTY_TEXT : getRawText(
|
RawText theirsText = theirs == null ? RawText.EMPTY_TEXT : getRawText(
|
||||||
theirs.getEntryObjectId(), db);
|
theirs.getEntryObjectId(), reader);
|
||||||
return (mergeAlgorithm.merge(RawTextComparator.DEFAULT, baseText,
|
return (mergeAlgorithm.merge(RawTextComparator.DEFAULT, baseText,
|
||||||
ourText, theirsText));
|
ourText, theirsText));
|
||||||
}
|
}
|
||||||
|
@ -866,11 +867,11 @@ private int mergeFileModes(int modeB, int modeO, int modeT) {
|
||||||
return FileMode.MISSING.getBits();
|
return FileMode.MISSING.getBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RawText getRawText(ObjectId id, Repository db)
|
private static RawText getRawText(ObjectId id, ObjectReader reader)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (id.equals(ObjectId.zeroId()))
|
if (id.equals(ObjectId.zeroId()))
|
||||||
return new RawText(new byte[] {});
|
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) {
|
private static boolean nonTree(final int mode) {
|
||||||
|
@ -1028,7 +1029,7 @@ protected boolean mergeTrees(AbstractTreeIterator baseTree,
|
||||||
builder = dircache.builder();
|
builder = dircache.builder();
|
||||||
DirCacheBuildIterator buildIt = new DirCacheBuildIterator(builder);
|
DirCacheBuildIterator buildIt = new DirCacheBuildIterator(builder);
|
||||||
|
|
||||||
tw = new NameConflictTreeWalk(db);
|
tw = new NameConflictTreeWalk(reader);
|
||||||
tw.addTree(baseTree);
|
tw.addTree(baseTree);
|
||||||
tw.addTree(headTree);
|
tw.addTree(headTree);
|
||||||
tw.addTree(mergeTree);
|
tw.addTree(mergeTree);
|
||||||
|
|
Loading…
Reference in New Issue