aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-10-08 00:18:42 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2021-10-08 00:18:42 +0200
commit4fd8c1406ff997579ef08d644b84b2f4757c9f11 (patch)
treee8a4ba4bf4cb859dc0de6f2d223bdc686d69f34f /org.eclipse.jgit/src/org/eclipse
parentae56213210d5b0976b332d177df680d1b9a62f60 (diff)
parent5f8c48413623ea4d1685063582c74a216207ef51 (diff)
downloadjgit-4fd8c1406ff997579ef08d644b84b2f4757c9f11.tar.gz
jgit-4fd8c1406ff997579ef08d644b84b2f4757c9f11.zip
Merge branch 'stable-5.6' into stable-5.7
* stable-5.6: reftable: drop code for truncated reads reftable: pass on invalid object ID in conversion Update eclipse-jarsigner-plugin to 1.3.2 Change-Id: I1c18f5f435f4a4a86e0548a310dbfc74191e1ed5
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java2
3 files changed, 16 insertions, 23 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
index e613a58062..c7053a16f8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
@@ -26,6 +26,7 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import org.eclipse.jgit.annotations.NonNull;
+import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.events.RefsChangedEvent;
import org.eclipse.jgit.internal.storage.reftable.MergedReftable;
import org.eclipse.jgit.internal.storage.reftable.ReftableBatchRefUpdate;
@@ -582,15 +583,20 @@ public class FileReftableDatabase extends RefDatabase {
r.getTarget().getName(), null));
}
ObjectId newId = r.getObjectId();
- RevObject obj = rw.parseAny(newId);
RevObject peel = null;
- if (obj instanceof RevTag) {
- peel = rw.peel(obj);
+ try {
+ RevObject obj = rw.parseAny(newId);
+ if (obj instanceof RevTag) {
+ peel = rw.peel(obj);
+ }
+ } catch (MissingObjectException e) {
+ /* ignore this error and copy the dangling object ID into reftable too. */
}
if (peel != null) {
- return new ObjectIdRef.PeeledTag(PACKED, r.getName(), newId,
- peel.copy());
- }
+ return new ObjectIdRef.PeeledTag(PACKED, r.getName(), newId,
+ peel.copy());
+ }
+
return new ObjectIdRef.PeeledNonTag(PACKED, r.getName(), newId);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
index 0096312892..d07713db8e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
@@ -59,7 +59,6 @@ import org.eclipse.jgit.util.RawParseUtils;
class BlockReader {
private byte blockType;
private long endPosition;
- private boolean truncated;
private byte[] buf;
private int bufLen;
@@ -79,10 +78,6 @@ class BlockReader {
return blockType;
}
- boolean truncated() {
- return truncated;
- }
-
long endPosition() {
return endPosition;
}
@@ -298,16 +293,8 @@ class BlockReader {
// Log blocks must be inflated after the header.
long deflatedSize = inflateBuf(src, pos, blockLen, fileBlockSize);
endPosition = pos + 4 + deflatedSize;
- }
- if (bufLen < blockLen) {
- if (blockType != INDEX_BLOCK_TYPE) {
- throw invalidBlock();
- }
- // Its OK during sequential scan for an index block to have been
- // partially read and be truncated in-memory. This happens when
- // the index block is larger than the file's blockSize. Caller
- // will break out of its scan loop once it sees the blockType.
- truncated = true;
+ } else if (bufLen < blockLen) {
+ readBlockIntoBuf(src, pos, blockLen);
} else if (bufLen > blockLen) {
bufLen = blockLen;
}
@@ -372,7 +359,7 @@ class BlockReader {
}
void verifyIndex() throws IOException {
- if (blockType != INDEX_BLOCK_TYPE || truncated) {
+ if (blockType != INDEX_BLOCK_TYPE) {
throw invalidBlock();
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
index 095276f57b..1e78855784 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
@@ -435,7 +435,7 @@ public class ReftableReader extends Reftable implements AutoCloseable {
BlockReader b = new BlockReader();
b.readBlock(src, pos, sz);
- if (b.type() == INDEX_BLOCK_TYPE && !b.truncated()) {
+ if (b.type() == INDEX_BLOCK_TYPE) {
if (indexCache == null) {
indexCache = new LongMap<>();
}