Merge branch 'stable-5.7' into stable-5.8
* stable-5.7: reftable: drop code for truncated reads reftable: pass on invalid object ID in conversion Update eclipse-jarsigner-plugin to 1.3.2 Change-Id: I88c47ff57f4829baec5b19aad3d8d6bd21f31a86
This commit is contained in:
commit
721a971d5d
|
@ -294,7 +294,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.cbi.maven.plugins</groupId>
|
<groupId>org.eclipse.cbi.maven.plugins</groupId>
|
||||||
<artifactId>eclipse-jarsigner-plugin</artifactId>
|
<artifactId>eclipse-jarsigner-plugin</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>1.3.2</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
|
|
@ -25,7 +25,9 @@
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -129,20 +131,21 @@ public void testConvert() throws Exception {
|
||||||
assertTrue(db.getRefDatabase().hasFastTipsWithSha1());
|
assertTrue(db.getRefDatabase().hasFastTipsWithSha1());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConvertToRefdir() throws Exception {
|
public void testConvertBrokenObjectId() throws Exception {
|
||||||
db.convertToPackedRefs(false, false);
|
db.convertToPackedRefs(false, false);
|
||||||
assertTrue(db.getRefDatabase() instanceof RefDirectory);
|
new File(db.getDirectory(), "refs/heads").mkdirs();
|
||||||
Ref h = db.exactRef("HEAD");
|
|
||||||
assertTrue(h.isSymbolic());
|
|
||||||
assertEquals("refs/heads/master", h.getTarget().getName());
|
|
||||||
|
|
||||||
Ref b = db.exactRef("refs/heads/b");
|
String invalidId = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
|
||||||
assertFalse(b.isSymbolic());
|
File headFile = new File(db.getDirectory(), "refs/heads/broken");
|
||||||
assertTrue(b.isPeeled());
|
try (OutputStream os = new FileOutputStream(headFile)) {
|
||||||
assertEquals(bCommit, b.getObjectId().name());
|
os.write(Constants.encodeASCII(invalidId + "\n"));
|
||||||
|
}
|
||||||
|
|
||||||
assertFalse(db.getRefDatabase().hasFastTipsWithSha1());
|
Ref r = db.exactRef("refs/heads/broken");
|
||||||
|
assertNotNull(r);
|
||||||
|
db.convertToReftable(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -803,6 +803,12 @@ public void logScan() throws IOException {
|
||||||
}
|
}
|
||||||
assertFalse(lc.next());
|
assertFalse(lc.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Ref exp : refs) {
|
||||||
|
try (LogCursor lc = t.seekLog(exp.getName())) {
|
||||||
|
assertTrue("has " + exp.getName(), lc.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.jgit.annotations.NonNull;
|
import org.eclipse.jgit.annotations.NonNull;
|
||||||
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
import org.eclipse.jgit.events.RefsChangedEvent;
|
import org.eclipse.jgit.events.RefsChangedEvent;
|
||||||
import org.eclipse.jgit.internal.storage.reftable.MergedReftable;
|
import org.eclipse.jgit.internal.storage.reftable.MergedReftable;
|
||||||
import org.eclipse.jgit.internal.storage.reftable.ReftableBatchRefUpdate;
|
import org.eclipse.jgit.internal.storage.reftable.ReftableBatchRefUpdate;
|
||||||
|
@ -582,15 +583,20 @@ private static Ref refForWrite(RevWalk rw, Ref r) throws IOException {
|
||||||
r.getTarget().getName(), null));
|
r.getTarget().getName(), null));
|
||||||
}
|
}
|
||||||
ObjectId newId = r.getObjectId();
|
ObjectId newId = r.getObjectId();
|
||||||
RevObject obj = rw.parseAny(newId);
|
|
||||||
RevObject peel = null;
|
RevObject peel = null;
|
||||||
|
try {
|
||||||
|
RevObject obj = rw.parseAny(newId);
|
||||||
if (obj instanceof RevTag) {
|
if (obj instanceof RevTag) {
|
||||||
peel = rw.peel(obj);
|
peel = rw.peel(obj);
|
||||||
}
|
}
|
||||||
|
} catch (MissingObjectException e) {
|
||||||
|
/* ignore this error and copy the dangling object ID into reftable too. */
|
||||||
|
}
|
||||||
if (peel != null) {
|
if (peel != null) {
|
||||||
return new ObjectIdRef.PeeledTag(PACKED, r.getName(), newId,
|
return new ObjectIdRef.PeeledTag(PACKED, r.getName(), newId,
|
||||||
peel.copy());
|
peel.copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ObjectIdRef.PeeledNonTag(PACKED, r.getName(), newId);
|
return new ObjectIdRef.PeeledNonTag(PACKED, r.getName(), newId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
class BlockReader {
|
class BlockReader {
|
||||||
private byte blockType;
|
private byte blockType;
|
||||||
private long endPosition;
|
private long endPosition;
|
||||||
private boolean truncated;
|
|
||||||
|
|
||||||
private byte[] buf;
|
private byte[] buf;
|
||||||
private int bufLen;
|
private int bufLen;
|
||||||
|
@ -79,10 +78,6 @@ byte type() {
|
||||||
return blockType;
|
return blockType;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean truncated() {
|
|
||||||
return truncated;
|
|
||||||
}
|
|
||||||
|
|
||||||
long endPosition() {
|
long endPosition() {
|
||||||
return endPosition;
|
return endPosition;
|
||||||
}
|
}
|
||||||
|
@ -298,16 +293,8 @@ private void parseBlockStart(BlockSource src, long pos, int fileBlockSize)
|
||||||
// Log blocks must be inflated after the header.
|
// Log blocks must be inflated after the header.
|
||||||
long deflatedSize = inflateBuf(src, pos, blockLen, fileBlockSize);
|
long deflatedSize = inflateBuf(src, pos, blockLen, fileBlockSize);
|
||||||
endPosition = pos + 4 + deflatedSize;
|
endPosition = pos + 4 + deflatedSize;
|
||||||
}
|
} else if (bufLen < blockLen) {
|
||||||
if (bufLen < blockLen) {
|
readBlockIntoBuf(src, pos, 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) {
|
} else if (bufLen > blockLen) {
|
||||||
bufLen = blockLen;
|
bufLen = blockLen;
|
||||||
}
|
}
|
||||||
|
@ -372,7 +359,7 @@ private void setupEmptyFileBlock() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void verifyIndex() throws IOException {
|
void verifyIndex() throws IOException {
|
||||||
if (blockType != INDEX_BLOCK_TYPE || truncated) {
|
if (blockType != INDEX_BLOCK_TYPE) {
|
||||||
throw invalidBlock();
|
throw invalidBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -435,7 +435,7 @@ private BlockReader readBlock(long pos, long end) throws IOException {
|
||||||
|
|
||||||
BlockReader b = new BlockReader();
|
BlockReader b = new BlockReader();
|
||||||
b.readBlock(src, pos, sz);
|
b.readBlock(src, pos, sz);
|
||||||
if (b.type() == INDEX_BLOCK_TYPE && !b.truncated()) {
|
if (b.type() == INDEX_BLOCK_TYPE) {
|
||||||
if (indexCache == null) {
|
if (indexCache == null) {
|
||||||
indexCache = new LongMap<>();
|
indexCache = new LongMap<>();
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -321,7 +321,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.cbi.maven.plugins</groupId>
|
<groupId>org.eclipse.cbi.maven.plugins</groupId>
|
||||||
<artifactId>eclipse-jarsigner-plugin</artifactId>
|
<artifactId>eclipse-jarsigner-plugin</artifactId>
|
||||||
<version>1.1.7</version>
|
<version>1.3.2</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.tycho.extras</groupId>
|
<groupId>org.eclipse.tycho.extras</groupId>
|
||||||
|
|
Loading…
Reference in New Issue