aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit
diff options
context:
space:
mode:
authorkylezhao <kylezhao@tencent.com>2023-04-03 17:04:38 +0800
committerMatthias Sohn <matthias.sohn@sap.com>2023-04-06 20:05:13 +0200
commitd3ba40c803beaa4351d955ddf0ce7c8d7e9d2322 (patch)
tree7caf8dbb719d4049bb1c5103c09f908dbd6f3fb2 /org.eclipse.jgit/src/org/eclipse/jgit
parent17fac8a27efd5c8b3028b9c244353265b697fb9f (diff)
downloadjgit-d3ba40c803beaa4351d955ddf0ce7c8d7e9d2322.tar.gz
jgit-d3ba40c803beaa4351d955ddf0ce7c8d7e9d2322.zip
Ensure parsed RevCommitCG has derived data from commit-graph
If a RevCommitCG was newly created and called #parseCanonical(RevWalk, byte[]) method immediately, its flag was marked as PARSED, but no derived data was obtained from the commit-graph. This is different from what we expected. Change-Id: I5d417efa3c42d211f19e6acf255f761e84d84450 Signed-off-by: kylezhao <kylezhao@tencent.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommitCG.java21
2 files changed, 26 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
index e155a25638..b64c9ce906 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
@@ -125,7 +125,15 @@ public class RevCommit extends RevObject {
int inDegree;
- private byte[] buffer;
+ /**
+ * Raw unparsed commit body of the commit. Populated only
+ * after {@link #parseCanonical(RevWalk, byte[])} with
+ * {@link RevWalk#isRetainBody()} enable or after
+ * {@link #parseBody(RevWalk)} and {@link #parse(RevWalk, byte[])}.
+ *
+ * @since 6.5.1
+ */
+ protected byte[] buffer;
/**
* Create a new commit reference.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommitCG.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommitCG.java
index b68f65b68c..4d3664da11 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommitCG.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommitCG.java
@@ -46,8 +46,25 @@ class RevCommitCG extends RevCommit {
/** {@inheritDoc} */
@Override
+ void parseCanonical(RevWalk walk, byte[] raw) throws IOException {
+ if (walk.isRetainBody()) {
+ buffer = raw;
+ }
+ parseInGraph(walk);
+ }
+
+ /** {@inheritDoc} */
+ @Override
void parseHeaders(RevWalk walk) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
+ if (walk.isRetainBody()) {
+ super.parseBody(walk); // This parses header and body
+ return;
+ }
+ parseInGraph(walk);
+ }
+
+ private void parseInGraph(RevWalk walk) throws IOException {
CommitGraph graph = walk.commitGraph();
CommitGraph.CommitData data = graph.getCommitData(graphPosition);
if (data == null) {
@@ -78,11 +95,7 @@ class RevCommitCG extends RevCommit {
this.parents = pList;
}
}
-
flags |= PARSED;
- if (walk.isRetainBody()) {
- super.parseBody(walk);
- }
}
/** {@inheritDoc} */