summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-04-20 14:42:56 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2023-04-20 14:58:50 +0200
commit48b0781cfe0c5e6616c5d2b51b8d7c7f070bb91e (patch)
tree24c2ec677388b9f91ac2d79a84ac4b1108460eb3
parentc7335f32e93b005fe681ed91873396a6d07886ad (diff)
parent4f662a26f981f0d2c21a8b288ad4165812988a48 (diff)
downloadjgit-48b0781cfe0c5e6616c5d2b51b8d7c7f070bb91e.tar.gz
jgit-48b0781cfe0c5e6616c5d2b51b8d7c7f070bb91e.zip
Merge branch 'stable-5.10' into stable-5.11
* stable-5.10: Add missing since tag for SshTestHarness#publicKey2 Silence API errors Prevent infinite loop rescanning the pack list on PackMismatchException Remove blank in maven.config Migrated "Prevent infinite loop rescanning the pack list on PackMismatchException" to refactoring done in https://git.eclipse.org/r/q/topic:restore-preserved-packs Change-Id: I0fb77bb9b498d48d5da88a93486b99bf8121e3bd
-rw-r--r--.mvn/maven.config2
-rw-r--r--org.eclipse.jgit.archive/.settings/.api_filters11
-rw-r--r--org.eclipse.jgit.junit.ssh/.settings/.api_filters25
-rw-r--r--org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java3
-rw-r--r--org.eclipse.jgit/.settings/.api_filters57
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java29
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java25
8 files changed, 87 insertions, 75 deletions
diff --git a/.mvn/maven.config b/.mvn/maven.config
index ebbe28853d..3944d880ef 100644
--- a/.mvn/maven.config
+++ b/.mvn/maven.config
@@ -1 +1 @@
--T 1C
+-T1C
diff --git a/org.eclipse.jgit.archive/.settings/.api_filters b/org.eclipse.jgit.archive/.settings/.api_filters
deleted file mode 100644
index f4a934aeb9..0000000000
--- a/org.eclipse.jgit.archive/.settings/.api_filters
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.jgit.archive" version="2">
- <resource path="src/org/eclipse/jgit/archive/BaseFormat.java" type="org.eclipse.jgit.archive.BaseFormat">
- <filter id="336658481">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.archive.BaseFormat"/>
- <message_argument value="COMPRESSION_LEVEL"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
diff --git a/org.eclipse.jgit.junit.ssh/.settings/.api_filters b/org.eclipse.jgit.junit.ssh/.settings/.api_filters
new file mode 100644
index 0000000000..44c9dfae49
--- /dev/null
+++ b/org.eclipse.jgit.junit.ssh/.settings/.api_filters
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.jgit.junit.ssh" version="2">
+ <resource path="src/org/eclipse/jgit/junit/ssh/SshTestHarness.java" type="org.eclipse.jgit.junit.ssh.SshTestHarness">
+ <filter id="336658481">
+ <message_arguments>
+ <message_argument value="org.eclipse.jgit.junit.ssh.SshTestHarness"/>
+ <message_argument value="publicKey2"/>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF">
+ <filter id="923795461">
+ <message_arguments>
+ <message_argument value="5.11.2"/>
+ <message_argument value="5.10.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/jgit/junit/ssh/SshTestBase.java" type="org.eclipse.jgit.junit.ssh.SshTestBase">
+ <filter id="338792546">
+ <message_arguments>
+ <message_argument value="org.eclipse.jgit.junit.ssh.SshTestBase"/>
+ <message_argument value="testSshWithConfig()"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java
index 90d981b772..a28d5ebd98 100644
--- a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java
+++ b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestHarness.java
@@ -76,6 +76,9 @@ public abstract class SshTestHarness extends RepositoryTestCase {
protected File publicKey1;
+ /**
+ * @since 5.10
+ */
protected File publicKey2;
protected SshTestGitServer server;
diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters
deleted file mode 100644
index d389ac5888..0000000000
--- a/org.eclipse.jgit/.settings/.api_filters
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.jgit" version="2">
- <resource path="src/org/eclipse/jgit/lib/ConfigConstants.java" type="org.eclipse.jgit.lib.ConfigConstants">
- <filter id="338755678">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.lib.ConfigConstants"/>
- <message_argument value="CONFIG_REFSTORAGE_REFTREE"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/revwalk/ObjectWalk.java" type="org.eclipse.jgit.revwalk.ObjectWalk">
- <filter id="421654647">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.revwalk.ObjectWalk"/>
- <message_argument value="createObjectReachabilityChecker()"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/revwalk/RevWalk.java" type="org.eclipse.jgit.revwalk.RevWalk">
- <filter id="421654647">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.revwalk.RevWalk"/>
- <message_argument value="createReachabilityChecker()"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/util/FS.java" type="org.eclipse.jgit.util.FS">
- <filter id="338792546">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.util.FS"/>
- <message_argument value="internalRunHookIfPresent(Repository, String, String[], PrintStream, PrintStream, String)"/>
- </message_arguments>
- </filter>
- <filter id="338792546">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.util.FS"/>
- <message_argument value="runHookIfPresent(Repository, String, String[], PrintStream, PrintStream, String)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/util/FS_POSIX.java" type="org.eclipse.jgit.util.FS_POSIX">
- <filter id="338792546">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.util.FS_POSIX"/>
- <message_argument value="runHookIfPresent(Repository, String, String[], PrintStream, PrintStream, String)"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/jgit/util/FS_Win32_Cygwin.java" type="org.eclipse.jgit.util.FS_Win32_Cygwin">
- <filter id="338792546">
- <message_arguments>
- <message_argument value="org.eclipse.jgit.util.FS_Win32_Cygwin"/>
- <message_argument value="runHookIfPresent(Repository, String, String[], PrintStream, PrintStream, String)"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java
index 44b8e0193c..7a2c70de79 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackMismatchException.java
@@ -18,6 +18,8 @@ import java.io.IOException;
public class PackMismatchException extends IOException {
private static final long serialVersionUID = 1L;
+ private boolean permanent;
+
/**
* Construct a pack modification error.
*
@@ -27,4 +29,31 @@ public class PackMismatchException extends IOException {
public PackMismatchException(String why) {
super(why);
}
+
+ /**
+ * Set the type of the exception
+ *
+ * @param permanent
+ * whether the exception is considered permanent
+ * @since 5.9.1
+ */
+ public void setPermanent(boolean permanent) {
+ this.permanent = permanent;
+ }
+
+ /**
+ * Check if this is a permanent problem
+ *
+ * @return if this is a permanent problem and repeatedly scanning the
+ * packlist couldn't fix it
+ * @since 5.9.1
+ */
+ public boolean isPermanent() {
+ return permanent;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + ", permanent: " + permanent; //$NON-NLS-1$
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
index 627facca02..a3ce3158ae 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectory.java
@@ -30,6 +30,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
+import org.eclipse.jgit.errors.PackMismatchException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.pack.ObjectToPack;
import org.eclipse.jgit.internal.storage.pack.PackExt;
@@ -350,7 +351,8 @@ public class ObjectDirectory extends FileObjectDatabase {
}
private ObjectLoader openPackedFromSelfOrAlternate(WindowCursor curs,
- AnyObjectId objectId, Set<AlternateHandle.Id> skips) {
+ AnyObjectId objectId, Set<AlternateHandle.Id> skips)
+ throws PackMismatchException {
ObjectLoader ldr = openPackedObject(curs, objectId);
if (ldr != null) {
return ldr;
@@ -386,7 +388,8 @@ public class ObjectDirectory extends FileObjectDatabase {
return null;
}
- ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId) {
+ ObjectLoader openPackedObject(WindowCursor curs, AnyObjectId objectId)
+ throws PackMismatchException {
return packed.open(curs, objectId);
}
@@ -421,7 +424,8 @@ public class ObjectDirectory extends FileObjectDatabase {
}
private long getPackedSizeFromSelfOrAlternate(WindowCursor curs,
- AnyObjectId id, Set<AlternateHandle.Id> skips) {
+ AnyObjectId id, Set<AlternateHandle.Id> skips)
+ throws PackMismatchException {
long len = packed.getSize(curs, id);
if (0 <= len) {
return len;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java
index 73745d8c64..73f6b4fffa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackDirectory.java
@@ -59,6 +59,8 @@ class PackDirectory {
private final static Logger LOG = LoggerFactory
.getLogger(PackDirectory.class);
+ private static final int MAX_PACKLIST_RESCAN_ATTEMPTS = 5;
+
private static final PackList NO_PACKS = new PackList(FileSnapshot.DIRTY,
new Pack[0]);
@@ -201,9 +203,11 @@ class PackDirectory {
return true;
}
- ObjectLoader open(WindowCursor curs, AnyObjectId objectId) {
+ ObjectLoader open(WindowCursor curs, AnyObjectId objectId)
+ throws PackMismatchException {
PackList pList;
do {
+ int retries = 0;
SEARCH: for (;;) {
pList = packList.get();
for (Pack p : pList.packs) {
@@ -215,6 +219,7 @@ class PackDirectory {
} catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list.
if (searchPacksAgain(pList)) {
+ retries = checkRescanPackThreshold(retries, e);
continue SEARCH;
}
} catch (IOException e) {
@@ -227,9 +232,11 @@ class PackDirectory {
return null;
}
- long getSize(WindowCursor curs, AnyObjectId id) {
+ long getSize(WindowCursor curs, AnyObjectId id)
+ throws PackMismatchException {
PackList pList;
do {
+ int retries = 0;
SEARCH: for (;;) {
pList = packList.get();
for (Pack p : pList.packs) {
@@ -242,6 +249,7 @@ class PackDirectory {
} catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list.
if (searchPacksAgain(pList)) {
+ retries = checkRescanPackThreshold(retries, e);
continue SEARCH;
}
} catch (IOException e) {
@@ -255,8 +263,9 @@ class PackDirectory {
}
void selectRepresentation(PackWriter packer, ObjectToPack otp,
- WindowCursor curs) {
+ WindowCursor curs) throws PackMismatchException {
PackList pList = packList.get();
+ int retries = 0;
SEARCH: for (;;) {
for (Pack p : pList.packs) {
try {
@@ -268,6 +277,7 @@ class PackDirectory {
} catch (PackMismatchException e) {
// Pack was modified; refresh the entire pack list.
//
+ retries = checkRescanPackThreshold(retries, e);
pList = scanPacks(pList);
continue SEARCH;
} catch (IOException e) {
@@ -278,6 +288,15 @@ class PackDirectory {
}
}
+ private int checkRescanPackThreshold(int retries, PackMismatchException e)
+ throws PackMismatchException {
+ if (retries++ > MAX_PACKLIST_RESCAN_ATTEMPTS) {
+ e.setPermanent(true);
+ throw e;
+ }
+ return retries;
+ }
+
private void handlePackError(IOException e, Pack p) {
String warnTmpl = null;
int transientErrorCount = 0;