diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-04-06 22:16:41 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-04-06 22:16:41 +0200 |
commit | 75db060673bf9cb241d1282259701c102e245d6a (patch) | |
tree | 4a84238747805c31171d415801bcaae8ee6209ee | |
parent | 3589c5cd1c0dc2b68880aa70728ff65566ad78da (diff) | |
parent | d3ba40c803beaa4351d955ddf0ce7c8d7e9d2322 (diff) | |
download | jgit-75db060673bf9cb241d1282259701c102e245d6a.tar.gz jgit-75db060673bf9cb241d1282259701c102e245d6a.zip |
Merge branch 'stable-6.5'
* stable-6.5:
Ensure parsed RevCommitCG has derived data from commit-graph
Downgrade maven-site-plugin to 3.12.1
Use wagon-ssh-external to deploy Maven site
Change-Id: Ide721fb088fa04f6276ac495968a45e732f6e139
-rw-r--r-- | org.eclipse.jgit.benchmarks/pom.xml | 6 | ||||
-rw-r--r-- | org.eclipse.jgit.packaging/pom.xml | 2 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java | 36 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java | 10 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommitCG.java | 21 | ||||
-rw-r--r-- | pom.xml | 6 |
6 files changed, 69 insertions, 12 deletions
diff --git a/org.eclipse.jgit.benchmarks/pom.xml b/org.eclipse.jgit.benchmarks/pom.xml index 16a1f00e9c..02cfe56d82 100644 --- a/org.eclipse.jgit.benchmarks/pom.xml +++ b/org.eclipse.jgit.benchmarks/pom.xml @@ -175,12 +175,12 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> - <version>4.0.0-M4</version> + <version>3.12.1</version> <dependencies> <dependency><!-- add support for ssh/scp --> <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ssh</artifactId> - <version>3.5.2</version> + <artifactId>wagon-ssh-external</artifactId> + <version>3.5.3</version> </dependency> </dependencies> </plugin> diff --git a/org.eclipse.jgit.packaging/pom.xml b/org.eclipse.jgit.packaging/pom.xml index 1f5d1a138d..eae7145871 100644 --- a/org.eclipse.jgit.packaging/pom.xml +++ b/org.eclipse.jgit.packaging/pom.xml @@ -313,7 +313,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> - <version>3.9.1</version> + <version>3.12.1</version> </plugin> </plugins> </pluginManagement> diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java index 6c8014513c..97d3f81b9b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkCommitGraphTest.java @@ -84,6 +84,42 @@ public class RevWalkCommitGraphTest extends RevWalkTestCase { } @Test + public void testParseCanonical() throws Exception { + RevCommit c1 = commitFile("file1", "1", "master"); + enableAndWriteCommitGraph(); + + RevCommit notParseInGraph = rw.lookupCommit(c1); + rw.parseHeaders(notParseInGraph); + + reinitializeRevWalk(); + RevCommit parseInGraph = rw.lookupCommit(c1); + parseInGraph.parseCanonical(rw, rw.getCachedBytes(c1)); + + assertTrue(parseInGraph instanceof RevCommitCG); + assertNotNull(parseInGraph.getRawBuffer()); + assertEquals(1, parseInGraph.getGeneration()); + assertEquals(notParseInGraph.getId(), parseInGraph.getId()); + assertEquals(notParseInGraph.getTree(), parseInGraph.getTree()); + assertEquals(notParseInGraph.getCommitTime(), + parseInGraph.getCommitTime()); + assertArrayEquals(notParseInGraph.getParents(), + parseInGraph.getParents()); + + reinitializeRevWalk(); + rw.setRetainBody(false); + RevCommit noBody = rw.lookupCommit(c1); + noBody.parseCanonical(rw, rw.getCachedBytes(c1)); + + assertTrue(noBody instanceof RevCommitCG); + assertNull(noBody.getRawBuffer()); + assertEquals(1, noBody.getGeneration()); + assertEquals(notParseInGraph.getId(), noBody.getId()); + assertEquals(notParseInGraph.getTree(), noBody.getTree()); + assertEquals(notParseInGraph.getCommitTime(), noBody.getCommitTime()); + assertArrayEquals(notParseInGraph.getParents(), noBody.getParents()); + } + + @Test public void testInitializeShallowCommits() throws Exception { RevCommit c1 = commit(commit()); branch(c1, "master"); 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} */ @@ -344,12 +344,12 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> - <version>4.0.0-M4</version> + <version>3.12.1</version> <dependencies> <dependency><!-- add support for ssh/scp --> <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ssh</artifactId> - <version>3.5.2</version> + <artifactId>wagon-ssh-external</artifactId> + <version>3.5.3</version> </dependency> </dependencies> </plugin> |