aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WORKSPACE28
-rw-r--r--org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.32.target24
-rw-r--r--org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.33.target24
-rw-r--r--org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target24
-rw-r--r--org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target24
-rw-r--r--org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd22
-rw-r--r--org.eclipse.jgit.packaging/pom.xml6
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/blame/BlameGeneratorCacheTest.java194
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java44
-rw-r--r--pom.xml8
10 files changed, 285 insertions, 113 deletions
diff --git a/WORKSPACE b/WORKSPACE
index 505141c472..9d1cc2bc58 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -204,8 +204,8 @@ maven_jar(
maven_jar(
name = "mockito",
- artifact = "org.mockito:mockito-core:5.15.2",
- sha1 = "87be4b1e0cc5febc07ab3197a8ff3ede56b37a79",
+ artifact = "org.mockito:mockito-core:5.16.0",
+ sha1 = "bd466e0926d691891f8f38823e0cbdcec6754358",
)
maven_jar(
@@ -214,18 +214,18 @@ maven_jar(
sha1 = "31f5d58a202bd5df4993fb10fa2cffd610c20d6f",
)
-BYTE_BUDDY_VERSION = "1.17.1"
+BYTE_BUDDY_VERSION = "1.17.2"
maven_jar(
name = "bytebuddy",
artifact = "net.bytebuddy:byte-buddy:" + BYTE_BUDDY_VERSION,
- sha1 = "8b5205fad48196a88d3d66dddff5a7417bce3596",
+ sha1 = "6fe75b66ba1a6ae30e373d696c3bbe34cd851e49",
)
maven_jar(
name = "bytebuddy-agent",
artifact = "net.bytebuddy:byte-buddy-agent:" + BYTE_BUDDY_VERSION,
- sha1 = "0669a13b59d5ffd8198a79e4dc99018a9278e457",
+ sha1 = "64e09840ffb6ed463c40c8f1e758486e5122d891",
)
maven_jar(
@@ -240,54 +240,54 @@ maven_jar(
sha1 = "4e773a317740b83b43cfc3d652962856041697cb",
)
-JETTY_VER = "12.0.16"
+JETTY_VER = "12.0.17"
maven_jar(
name = "jetty-servlet",
artifact = "org.eclipse.jetty.ee10:jetty-ee10-servlet:" + JETTY_VER,
- sha1 = "022a746c00b1ac5c790fee65a398c707160a46d8",
+ sha1 = "fc936f788d9abf29b5fd1a502d2be1dc38973f47",
)
maven_jar(
name = "jetty-security",
artifact = "org.eclipse.jetty:jetty-security:" + JETTY_VER,
- sha1 = "23b1a3abecf9d6f5498064a32d9145ae1d8330f9",
+ sha1 = "8d7ec1c2d3fb13ca2f244e318a8bb1f3fcb79020",
)
maven_jar(
name = "jetty-server",
artifact = "org.eclipse.jetty:jetty-server:" + JETTY_VER,
- sha1 = "3e3638b4bfbee04c27b3ae68e4949fc43b40a042",
+ sha1 = "0692b8368eafcc014afb72be549379c97f4f1114",
)
maven_jar(
name = "jetty-session",
artifact = "org.eclipse.jetty:jetty-session:" + JETTY_VER,
- sha1 = "79cdedc7afebbdba4453f603dfe2f970baa35cc3",
+ sha1 = "1c475d0698ab717b656850712522901ff4cd9680",
)
maven_jar(
name = "jetty-http",
artifact = "org.eclipse.jetty:jetty-http:" + JETTY_VER,
- sha1 = "68019fa90e8420ae15c109bd8c8611cacbaf43e5",
+ sha1 = "b7d355158fb2251ef3b2a43c3afa64f219c1065f",
)
maven_jar(
name = "jetty-io",
artifact = "org.eclipse.jetty:jetty-io:" + JETTY_VER,
- sha1 = "7a162c537a99bbaf35a074fec9a50815e6c81d9d",
+ sha1 = "c2565402319b88d89e3094246aeb299730ff09e0",
)
maven_jar(
name = "jetty-util",
artifact = "org.eclipse.jetty:jetty-util:" + JETTY_VER,
- sha1 = "e262e505363e5925df15618622d9888aefc1b0d0",
+ sha1 = "f3c503a597def913e572f167f32e30b9a067022f",
)
maven_jar(
name = "jetty-util-ajax",
artifact = "org.eclipse.jetty:jetty-util-ajax:" + JETTY_VER,
- sha1 = "60225034131e3f771b40bc75c15bd9cc4952302b",
+ sha1 = "c5aaccff6f2a767594cb57fc29889f53d2dc3643",
)
BOUNCYCASTLE_VER = "1.80"
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.32.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.32.target
index 60baf0b7cf..82444c2d86 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.32.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.32.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.32" sequenceNumber="1740521280">
+<target name="jgit-4.32" sequenceNumber="1741469599">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/>
@@ -77,7 +77,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>5.15.2</version>
+ <version>5.16.0</version>
<type>jar</type>
</dependency>
</dependencies>
@@ -103,49 +103,49 @@
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-session</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util-ajax</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
@@ -191,13 +191,13 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
- <version>1.17.1</version>
+ <version>1.17.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
- <version>1.17.1</version>
+ <version>1.17.2</version>
<type>jar</type>
</dependency>
</dependencies>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.33.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.33.target
index 1558ad68fc..b38e1a2874 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.33.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.33.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.33" sequenceNumber="1740521283">
+<target name="jgit-4.33" sequenceNumber="1741469599">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/>
@@ -77,7 +77,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>5.15.2</version>
+ <version>5.16.0</version>
<type>jar</type>
</dependency>
</dependencies>
@@ -103,49 +103,49 @@
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-session</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util-ajax</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
@@ -191,13 +191,13 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
- <version>1.17.1</version>
+ <version>1.17.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
- <version>1.17.1</version>
+ <version>1.17.2</version>
<type>jar</type>
</dependency>
</dependencies>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target
index bc35d2c7eb..45440cddfb 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.34" sequenceNumber="1740521284">
+<target name="jgit-4.34" sequenceNumber="1741469599">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/>
@@ -77,7 +77,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>5.15.2</version>
+ <version>5.16.0</version>
<type>jar</type>
</dependency>
</dependencies>
@@ -103,49 +103,49 @@
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-session</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util-ajax</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
@@ -191,13 +191,13 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
- <version>1.17.1</version>
+ <version>1.17.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
- <version>1.17.1</version>
+ <version>1.17.2</version>
<type>jar</type>
</dependency>
</dependencies>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target
index 15cabc3d1f..45d20113e8 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
-<target name="jgit-4.35" sequenceNumber="1740521286">
+<target name="jgit-4.35" sequenceNumber="1741469599">
<locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/>
@@ -77,7 +77,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>5.15.2</version>
+ <version>5.16.0</version>
<type>jar</type>
</dependency>
</dependencies>
@@ -103,49 +103,49 @@
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-security</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-session</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util-ajax</artifactId>
- <version>12.0.16</version>
+ <version>12.0.17</version>
<type>jar</type>
</dependency>
<dependency>
@@ -191,13 +191,13 @@
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
- <version>1.17.1</version>
+ <version>1.17.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
- <version>1.17.1</version>
+ <version>1.17.2</version>
<type>jar</type>
</dependency>
</dependencies>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd
index b292cf5e84..df106917e2 100644
--- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd
+++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd
@@ -97,12 +97,12 @@ maven bytebuddy
dependency {
groupId = "net.bytebuddy"
artifactId = "byte-buddy"
- version = "1.17.1"
+ version = "1.17.2"
}
dependency {
groupId = "net.bytebuddy"
artifactId = "byte-buddy-agent"
- version = "1.17.1"
+ version = "1.17.2"
}
}
@@ -154,42 +154,42 @@ maven jetty
dependency {
groupId = "org.eclipse.jetty.ee10"
artifactId = "jetty-ee10-servlet"
- version = "12.0.16"
+ version = "12.0.17"
}
dependency {
groupId = "org.eclipse.jetty"
artifactId = "jetty-http"
- version = "12.0.16"
+ version = "12.0.17"
}
dependency {
groupId = "org.eclipse.jetty"
artifactId = "jetty-io"
- version = "12.0.16"
+ version = "12.0.17"
}
dependency {
groupId = "org.eclipse.jetty"
artifactId = "jetty-security"
- version = "12.0.16"
+ version = "12.0.17"
}
dependency {
groupId = "org.eclipse.jetty"
artifactId = "jetty-server"
- version = "12.0.16"
+ version = "12.0.17"
}
dependency {
groupId = "org.eclipse.jetty"
artifactId = "jetty-session"
- version = "12.0.16"
+ version = "12.0.17"
}
dependency {
groupId = "org.eclipse.jetty"
artifactId = "jetty-util"
- version = "12.0.16"
+ version = "12.0.17"
}
dependency {
groupId = "org.eclipse.jetty"
artifactId = "jetty-util-ajax"
- version = "12.0.16"
+ version = "12.0.17"
}
dependency {
groupId = "jakarta.servlet"
@@ -225,7 +225,7 @@ maven mockito
dependency {
groupId = "org.mockito"
artifactId = "mockito-core"
- version = "5.15.2"
+ version = "5.16.0"
}
}
diff --git a/org.eclipse.jgit.packaging/pom.xml b/org.eclipse.jgit.packaging/pom.xml
index 6352d0aae3..8b25ff1674 100644
--- a/org.eclipse.jgit.packaging/pom.xml
+++ b/org.eclipse.jgit.packaging/pom.xml
@@ -30,7 +30,7 @@
<properties>
<java.version>17</java.version>
- <tycho-version>4.0.11</tycho-version>
+ <tycho-version>4.0.12</tycho-version>
<target-platform>jgit-4.32</target-platform>
<project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp>
</properties>
@@ -395,12 +395,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
- <version>3.1.3</version>
+ <version>3.1.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
- <version>3.1.3</version>
+ <version>3.1.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/blame/BlameGeneratorCacheTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/blame/BlameGeneratorCacheTest.java
index 65cac11982..3e4ac1f993 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/blame/BlameGeneratorCacheTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/blame/BlameGeneratorCacheTest.java
@@ -19,7 +19,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import org.eclipse.jgit.blame.cache.BlameCache;
import org.eclipse.jgit.blame.cache.CacheRegion;
@@ -46,7 +45,8 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
* L4 | *C2 C2 *C4 C4
* </pre>
*
- * @throws Exception any error
+ * @throws Exception
+ * any error
*/
@Test
public void blame_simple_correctRegions() throws Exception {
@@ -87,7 +87,64 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
assertCacheUsage(c4, blameAndCache(c4), true, 1);
assertCacheUsage(c4, blameAndCache(c3), true, 2);
assertCacheUsage(c4, blameAndCache(c2), true, 3);
- assertCacheUsage(c4, blameAndCache(c1), true, 4);
+ // Cache not needed because c1 doesn't have parents
+ assertCacheUsage(c4, blameAndCache(c1), false, 4);
+ }
+
+ @Test
+ public void blame_simple_createdMidHistory_correctRegions() throws Exception {
+ String c1Content = lines("L1C1", "L2C1", "L3C1");
+ String c2Content = lines("L1C1", "L2C1", "L3C1", "L4C2");
+ String c3Content = lines("L1C1", "L2C3", "L3C3", "L4C2");
+ String c4Content = lines("L1C1", "L2C4", "L3C3", "L4C4");
+
+ RevCommit c0, c1, c2, c3, c4;
+ try (TestRepository<FileRepository> r = new TestRepository<>(db)) {
+ c0 = r.commit().add("otherfile", "content").create();
+ c1 = r.commit().parent(c0).add(FILE, c1Content).create();
+ c2 = r.commit().parent(c1).add(FILE, c2Content).create();
+ c3 = r.commit().parent(c2).add(FILE, c3Content).create();
+ c4 = r.commit().parent(c3).add(FILE, c4Content).create();
+ }
+
+ List<EmittedRegion> expectedRegions = Arrays.asList(
+ new EmittedRegion(c1, 0, 1),
+ new EmittedRegion(c4, 1, 2),
+ new EmittedRegion(c3, 2, 3),
+ new EmittedRegion(c4, 3, 4));
+
+ assertRegions(c4, null, expectedRegions, 4);
+ assertRegions(c4, emptyCache(), expectedRegions, 4);
+ assertRegions(c4, blameAndCache(c4, FILE), expectedRegions, 4);
+ assertRegions(c4, blameAndCache(c3, FILE), expectedRegions, 4);
+ assertRegions(c4, blameAndCache(c2, FILE), expectedRegions, 4);
+ assertRegions(c4, blameAndCache(c1, FILE), expectedRegions, 4);
+ assertRegions(c4, blameAndCache(c0, FILE), expectedRegions, 4);
+ }
+
+ @Test
+ public void blame_simple_createdMidHistory_cacheUsage() throws Exception {
+ String c1Content = lines("L1C1", "L2C1", "L3C1");
+ String c2Content = lines("L1C1", "L2C1", "L3C1", "L4C2");
+ String c3Content = lines("L1C1", "L2C3", "L3C3", "L4C2");
+ String c4Content = lines("L1C1", "L2C4", "L3C3", "L4C4");
+
+ RevCommit c0, c1, c2, c3, c4;
+ try (TestRepository<FileRepository> r = new TestRepository<>(db)) {
+ c0 = r.commit().add("otherfile", "content").create();
+ c1 = r.commit().parent(c0).add(FILE, c1Content).create();
+ c2 = r.commit().parent(c1).add(FILE, c2Content).create();
+ c3 = r.commit().parent(c2).add(FILE, c3Content).create();
+ c4 = r.commit().parent(c3).add(FILE, c4Content).create();
+ }
+
+ assertCacheUsage(c4, null, false, 4);
+ assertCacheUsage(c4, emptyCache(), false, 4);
+ assertCacheUsage(c4, blameAndCache(c4, FILE), true, 1);
+ assertCacheUsage(c4, blameAndCache(c3, FILE), true, 2);
+ assertCacheUsage(c4, blameAndCache(c2, FILE), true, 3);
+ // Cache not needed because c1 created the file
+ assertCacheUsage(c4, blameAndCache(c1, FILE), false, 4);
}
/**
@@ -102,10 +159,11 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
* L4 | *C2
* </pre>
*
- * @throws Exception any error
+ * @throws Exception
+ * any error
*/
@Test
- public void blame_ovewrite_correctRegions() throws Exception {
+ public void blame_overwrite_correctRegions() throws Exception {
RevCommit c1, c2, c3;
try (TestRepository<FileRepository> r = new TestRepository<>(db)) {
c1 = commit(r, lines("L1C1", "L2C1", "L3C1"));
@@ -166,7 +224,8 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
* L8-L11 b (from sideB)
* </pre>
*
- * @throws Exception any error
+ * @throws Exception
+ * any error
*/
@Test
public void blame_merge_correctRegions() throws Exception {
@@ -204,14 +263,13 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
assertCacheUsage(mergedTip, null, /* cacheUsed */ false,
/* candidates */ 4);
assertCacheUsage(mergedTip, emptyCache(), false, 4);
- assertCacheUsage(mergedTip, blameAndCache(mergedTip), true, 1);
// While splitting unblamed regions to parents, sideA comes first
// and gets "aaaa----". Processing is by commit time, so sideB is
// explored first
assertCacheUsage(mergedTip, blameAndCache(sideA), true, 3);
assertCacheUsage(mergedTip, blameAndCache(sideB), true, 4);
- assertCacheUsage(mergedTip, blameAndCache(root), true, 4);
+ assertCacheUsage(mergedTip, blameAndCache(root), false, 4);
}
/**
@@ -226,7 +284,8 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
* L4 | C1 C1
* </pre>
*
- * @throws Exception any error
+ * @throws Exception
+ * any error
*/
@Test
public void blame_movingBlock_correctRegions() throws Exception {
@@ -263,7 +322,77 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
assertCacheUsage(c3, emptyCache(), false, 3);
assertCacheUsage(c3, blameAndCache(c3), true, 1);
assertCacheUsage(c3, blameAndCache(c2), true, 2);
- assertCacheUsage(c3, blameAndCache(c1), true, 3);
+ assertCacheUsage(c3, blameAndCache(c1), false, 3);
+ }
+
+ @Test
+ public void blame_cacheOnlyOnChange_unmodifiedInSomeCommits_cacheUsage() throws Exception {
+ String README = "README";
+ String fileC1Content = lines("L1C1", "L2C1", "L3C1");
+ String fileC2Content = lines("L1C1", "L2C1", "L3C1", "L4C2");
+ String fileC3Content = lines("L1C1", "L2C3", "L3C3", "L4C2");
+ String fileC4Content = lines("L1C1", "L2C4", "L3C3", "L4C4");
+
+ RevCommit c1, c2, c3, c4, ni;
+ try (TestRepository<FileRepository> r = new TestRepository<>(db)) {
+ c1 = r.commit().add(FILE, fileC1Content).create();
+ c2 = r.commit().parent(c1).add(FILE, fileC2Content).create();
+ // Keep FILE and edit 100 times README
+ ni = c2;
+ for (int i = 0; i < 100; i++) {
+ ni = r.commit().parent(ni).add(README, "whatever " + i).create();
+ }
+ c3 = r.commit().parent(ni).add(FILE, fileC3Content).create();
+ c4 = r.commit().parent(c3).add(FILE, fileC4Content).create();
+ r.branch("refs/heads/master").update(c4);
+ }
+
+ InMemoryBlameCache empty = emptyCache();
+ assertCacheUsage(c4, empty, false, 104);
+ assertEquals(3, empty.callCount);
+
+ InMemoryBlameCache c4Cached = blameAndCache(c4, FILE);
+ assertCacheUsage(c4, c4Cached, true, 1);
+ assertEquals(1, c4Cached.callCount);
+
+ InMemoryBlameCache c3Cached = blameAndCache(c3, FILE);
+ assertCacheUsage(c4, c3Cached, true, 2);
+ assertEquals(2, c3Cached.callCount);
+
+ // This commit doesn't touch the file, shouldn't check the cache
+ InMemoryBlameCache niCached = blameAndCache(ni, FILE);
+ assertCacheUsage(c4, niCached, false, 104);
+ assertEquals(3, niCached.callCount);
+
+ InMemoryBlameCache c2Cached = blameAndCache(c2, FILE);
+ assertCacheUsage(c4, c2Cached, true, 103);
+ assertEquals(3, c2Cached.callCount);
+
+ // No parents, c1 doesn't need cache.
+ InMemoryBlameCache c1Cached = blameAndCache(c1, FILE);
+ assertCacheUsage(c4, c1Cached, false, 104);
+ assertEquals(3, c1Cached.callCount);
+ }
+
+ @Test
+ public void blame_cacheOnlyOnChange_renameWithoutChange_cacheUsage() throws Exception {
+ String OTHER = "other.txt";
+ String c1Content = lines("L1C1", "L2C1", "L3C1");
+ String c2Content = lines("L1C1", "L2C1", "L3C1", "L4C2");
+
+ RevCommit c1, c2, c3;
+ try (TestRepository<FileRepository> r = new TestRepository<>(db)) {
+ c1 = r.commit().add(OTHER, c1Content).create();
+ c2 = r.commit().parent(c1).add(OTHER, c2Content).create();
+ c3 = r.commit().parent(c2).rm(OTHER).add(FILE, c2Content).create();
+ r.branch("refs/heads/master").update(c3);
+ }
+
+ assertCacheUsage(c3, null, false, 3);
+ assertCacheUsage(c3, emptyCache(), false, 3);
+ assertCacheUsage(c3, blameAndCache(c3, FILE), true, 1);
+ assertCacheUsage(c3, blameAndCache(c2, OTHER), true, 2);
+ assertCacheUsage(c3, blameAndCache(c1, OTHER), false, 3);
}
private void assertRegions(RevCommit commit, InMemoryBlameCache cache,
@@ -278,11 +407,11 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
}
private void assertCacheUsage(RevCommit commit, InMemoryBlameCache cache,
- boolean useCache, int candidatesVisited) throws IOException {
+ boolean cacheHit, int candidatesVisited) throws IOException {
try (BlameGenerator gen = new BlameGenerator(db, FILE, cache)) {
gen.push(null, db.parseCommit(commit));
consume(gen);
- assertEquals(useCache, gen.getStats().isCacheHit());
+ assertEquals(cacheHit, gen.getStats().isCacheHit());
assertEquals(candidatesVisited,
gen.getStats().getCandidatesVisited());
}
@@ -300,8 +429,8 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
regions.get(regions.size() - 1).resultEnd());
}
- private static void assertRegionsEquals(
- List<EmittedRegion> expected, List<EmittedRegion> actual) {
+ private static void assertRegionsEquals(List<EmittedRegion> expected,
+ List<EmittedRegion> actual) {
assertEquals(expected.size(), actual.size());
Collections.sort(actual);
for (int i = 0; i < expected.size(); i++) {
@@ -328,15 +457,20 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
private InMemoryBlameCache blameAndCache(RevCommit commit)
throws IOException {
+ return blameAndCache(commit, FILE);
+ }
+
+ private InMemoryBlameCache blameAndCache(RevCommit commit, String path)
+ throws IOException {
List<CacheRegion> regions;
- try (BlameGenerator generator = new BlameGenerator(db, FILE)) {
+ try (BlameGenerator generator = new BlameGenerator(db, path)) {
generator.push(null, commit);
regions = consume(generator).stream()
.map(EmittedRegion::asCacheRegion)
- .collect(Collectors.toUnmodifiableList());
+ .toList();
}
InMemoryBlameCache cache = new InMemoryBlameCache("<x>");
- cache.put(commit, FILE, regions);
+ cache.put(commit, path, regions);
return cache;
}
@@ -347,7 +481,24 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
private static RevCommit commit(TestRepository<?> r, String contents,
RevCommit... parents) throws Exception {
- return r.commit(r.tree(r.file(FILE, r.blob(contents))), parents);
+ return commit(r, Map.of(FILE, contents), parents);
+ }
+
+ private static RevCommit commit(TestRepository<?> r,
+ Map<String, String> fileContents, RevCommit... parents)
+ throws Exception {
+ TestRepository<?>.CommitBuilder builder = r.commit();
+ for (RevCommit commit : parents) {
+ builder.parent(commit);
+ }
+ fileContents.forEach((path, content) -> {
+ try {
+ builder.add(path, content);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ });
+ return builder.create();
}
private static String lines(String... l) {
@@ -372,18 +523,21 @@ public class BlameGeneratorCacheTest extends RepositoryTestCase {
private final String description;
+ private int callCount;
+
public InMemoryBlameCache(String description) {
this.description = description;
}
@Override
public List<CacheRegion> get(Repository repo, ObjectId commitId,
- String path) throws IOException {
+ String path) throws IOException {
+ callCount++;
return cache.get(new Key(commitId.name(), path));
}
public void put(ObjectId commitId, String path,
- List<CacheRegion> cachedRegions) {
+ List<CacheRegion> cachedRegions) {
cache.put(new Key(commitId.name(), path), cachedRegions);
}
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 2d499cafce..979c8cef88 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
@@ -652,19 +652,6 @@ public class BlameGenerator implements AutoCloseable {
if (n == null)
return done();
stats.candidatesVisited += 1;
- if (blameCache != null && useCache) {
- List<CacheRegion> cachedBlame = blameCache.get(repository,
- n.sourceCommit, n.sourcePath.getPath());
- if (cachedBlame != null) {
- BlameRegionMerger rb = new BlameRegionMerger(repository,
- revPool, cachedBlame);
- Candidate fullyBlamed = rb.mergeCandidate(n);
- if (fullyBlamed != null) {
- stats.cacheHit = true;
- return result(fullyBlamed);
- }
- }
- }
int pCnt = n.getParentCount();
if (pCnt == 1) {
@@ -769,6 +756,27 @@ public class BlameGenerator implements AutoCloseable {
}
}
+ @Nullable
+ private Candidate blameFromCache(Candidate n) throws IOException {
+ if (blameCache == null || !useCache) {
+ return null;
+ }
+
+ List<CacheRegion> cachedBlame = blameCache.get(repository,
+ n.sourceCommit, n.sourcePath.getPath());
+ if (cachedBlame == null) {
+ return null;
+ }
+ BlameRegionMerger rb = new BlameRegionMerger(repository, revPool,
+ cachedBlame);
+ Candidate fullyBlamed = rb.mergeCandidate(n);
+ if (fullyBlamed == null) {
+ return null;
+ }
+ stats.cacheHit = true;
+ return fullyBlamed;
+ }
+
private boolean processOne(Candidate n) throws IOException {
RevCommit parent = n.getParent(0);
if (parent == null)
@@ -791,12 +799,17 @@ public class BlameGenerator implements AutoCloseable {
if (0 == r.getOldId().prefixCompare(n.sourceBlob)) {
// A 100% rename without any content change can also
// skip directly to the parent.
+ Candidate cached = blameFromCache(n);
+ if (cached != null) {
+ return result(cached);
+ }
n.sourceCommit = parent;
n.sourcePath = PathFilter.create(r.getOldPath());
push(n);
return false;
}
+
Candidate next = n.create(getRepository(), parent,
PathFilter.create(r.getOldPath()));
next.sourceBlob = r.getOldId().toObjectId();
@@ -833,6 +846,11 @@ public class BlameGenerator implements AutoCloseable {
return false;
}
+ Candidate cached = blameFromCache(source);
+ if (cached != null) {
+ return result(cached);
+ }
+
parent.takeBlame(editList, source);
if (parent.regionList != null)
push(parent);
diff --git a/pom.xml b/pom.xml
index ecae118eb4..b03dc9fb35 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,7 +130,7 @@
<commons-compress-version>1.27.1</commons-compress-version>
<osgi-core-version>6.0.0</osgi-core-version>
<servlet-api-version>6.1.0</servlet-api-version>
- <jetty-version>12.0.16</jetty-version>
+ <jetty-version>12.0.17</jetty-version>
<japicmp-version>0.23.1</japicmp-version>
<httpclient-version>4.5.14</httpclient-version>
<httpcore-version>4.4.16</httpcore-version>
@@ -138,7 +138,7 @@
<maven-javadoc-plugin-version>3.11.2</maven-javadoc-plugin-version>
<gson-version>2.12.1</gson-version>
<bouncycastle-version>1.80</bouncycastle-version>
- <spotbugs-maven-plugin-version>4.9.1.0</spotbugs-maven-plugin-version>
+ <spotbugs-maven-plugin-version>4.9.2.0</spotbugs-maven-plugin-version>
<maven-project-info-reports-plugin-version>3.8.0</maven-project-info-reports-plugin-version>
<maven-jxr-plugin-version>3.6.0</maven-jxr-plugin-version>
<maven-surefire-plugin-version>3.5.2</maven-surefire-plugin-version>
@@ -148,7 +148,7 @@
<hamcrest-version>2.2</hamcrest-version>
<assertj-version>3.27.3</assertj-version>
<jna-version>5.16.0</jna-version>
- <byte-buddy-version>1.17.1</byte-buddy-version>
+ <byte-buddy-version>1.17.2</byte-buddy-version>
<!-- Properties to enable jacoco code coverage analysis -->
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
@@ -1007,7 +1007,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>5.15.2</version>
+ <version>5.16.0</version>
</dependency>
<dependency>