summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2014-08-15 10:21:32 -0700
committerShawn Pearce <spearce@spearce.org>2014-08-15 10:27:31 -0700
commit9bb891e44d23f87e3a97710ffdf877c2ec10b8ee (patch)
treedff8710869fb9d4310fac86864f3089d3a13cae9
parent94c4d7eee85d5ffe19d04c5a6e60192430d4fe1e (diff)
downloadjgit-9bb891e44d23f87e3a97710ffdf877c2ec10b8ee.tar.gz
jgit-9bb891e44d23f87e3a97710ffdf877c2ec10b8ee.zip
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
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java13
2 files changed, 8 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.java
index 4889293ad0..713eb447dc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/RecursiveMerger.java
@@ -265,7 +265,7 @@ public class RecursiveMerger extends ResolveMerger {
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()) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
index f77d72ae54..fb9abf8097 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
@@ -81,6 +81,7 @@ import org.eclipse.jgit.internal.JGitText;
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 @@ public class ResolveMerger extends ThreeWayMerger {
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 @@ public class ResolveMerger extends ThreeWayMerger {
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 @@ public class ResolveMerger extends ThreeWayMerger {
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);