Browse Source

PackFile: report correct message for checksum mismatch

When the packfile checksum does not match the expected one
report the correct checksum error instead of reporting that
the number of objects is incorrect.

Change-Id: I040f36dacc4152ae05453e7acbf8dfccceb46e0d
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.1
Luca Milanesio 6 years ago committed by Matthias Sohn
parent
commit
436c99ce59
  1. 2
      org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
  2. 11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

2
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties

@ -509,7 +509,7 @@ openingConnection=Opening connection
operationCanceled=Operation {0} was canceled operationCanceled=Operation {0} was canceled
outputHasAlreadyBeenStarted=Output has already been started. outputHasAlreadyBeenStarted=Output has already been started.
overflowedReftableBlock=Overflowed reftable block overflowedReftableBlock=Overflowed reftable block
packChecksumMismatch=Pack checksum mismatch detected for pack file {0} packChecksumMismatch=Pack checksum mismatch detected for pack file {0}: .pack has {1} whilst .idx has {2}
packCorruptedWhileWritingToFilesystem=Pack corrupted while writing to filesystem packCorruptedWhileWritingToFilesystem=Pack corrupted while writing to filesystem
packDoesNotMatchIndex=Pack {0} does not match index packDoesNotMatchIndex=Pack {0} does not match index
packedRefsHandleIsStale=packed-refs handle is stale, {0}. retry packedRefsHandleIsStale=packed-refs handle is stale, {0}. retry

11
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java

@ -187,7 +187,8 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
} else if (!Arrays.equals(packChecksum, idx.packChecksum)) { } else if (!Arrays.equals(packChecksum, idx.packChecksum)) {
throw new PackMismatchException(MessageFormat.format( throw new PackMismatchException(MessageFormat.format(
JGitText.get().packChecksumMismatch, JGitText.get().packChecksumMismatch,
packFile.getPath())); packFile.getPath(), packChecksum,
idx.packChecksum));
} }
loadedIdx = idx; loadedIdx = idx;
} catch (InterruptedIOException e) { } catch (InterruptedIOException e) {
@ -753,10 +754,10 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
fd.readFully(buf, 0, 20); fd.readFully(buf, 0, 20);
if (!Arrays.equals(buf, packChecksum)) { if (!Arrays.equals(buf, packChecksum)) {
throw new PackMismatchException(MessageFormat.format( throw new PackMismatchException(MessageFormat.format(
JGitText.get().packObjectCountMismatch JGitText.get().packChecksumMismatch,
, ObjectId.fromRaw(buf).name() getPackFile(),
, ObjectId.fromRaw(idx.packChecksum).name() ObjectId.fromRaw(buf).name(),
, getPackFile())); ObjectId.fromRaw(idx.packChecksum).name()));
} }
} }

Loading…
Cancel
Save