Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce2014-04-20 03:02:19 +0000
committerShawn Pearce2014-04-21 18:43:02 +0000
commit2ee4d4a2c732171cd33d373df49093ff8ff4b775 (patch)
treeee170a0b93e75b9645abe52d29f7ef6796b1b4fc
parent6afae79901f7d3fe7598c81f7474bc98c29909b9 (diff)
downloadjgit-2ee4d4a2c732171cd33d373df49093ff8ff4b775.tar.gz
jgit-2ee4d4a2c732171cd33d373df49093ff8ff4b775.tar.xz
jgit-2ee4d4a2c732171cd33d373df49093ff8ff4b775.zip
blame: Allow candidate to manage its setup before output
Pass in the RevWalk and let the candidate decide how to prepare itself for output. This removes the conditional for the missing sourceCommit, as candidates missing a commit can override the method with a no-op. Change-Id: I3fa19b8676dfd3c177583f8f42593b5000b5350d
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java11
2 files changed, 12 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
index d90d59824d..dd6717b6dd 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
@@ -519,8 +519,7 @@ public class BlameGenerator {
}
private boolean result(Candidate n) throws IOException {
- if (n.sourceCommit != null)
- revPool.parseBody(n.sourceCommit);
+ n.beginResult(revPool);
outCandidate = n;
outRegion = n.regionList;
return true;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java b/org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java
index a652278d05..c7c34f0a3a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/Candidate.java
@@ -49,6 +49,7 @@ import org.eclipse.jgit.blame.ReverseWalk.ReverseCommit;
import org.eclipse.jgit.diff.Edit;
import org.eclipse.jgit.diff.EditList;
import org.eclipse.jgit.diff.RawText;
+import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
@@ -56,6 +57,7 @@ import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevFlag;
+import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.treewalk.filter.PathFilter;
/**
@@ -114,6 +116,10 @@ class Candidate {
recursivePath = path.shouldBeRecursive();
}
+ void beginResult(RevWalk rw) throws MissingObjectException, IOException {
+ rw.parseBody(sourceCommit);
+ }
+
int getParentCount() {
return sourceCommit.getParentCount();
}
@@ -406,6 +412,11 @@ class Candidate {
}
@Override
+ void beginResult(RevWalk rw) {
+ // Blob candidates have nothing to prepare.
+ }
+
+ @Override
int getParentCount() {
return parent != null ? 1 : 0;
}

Back to the top